~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_atomicfile.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-09 15:57:23 UTC
  • mto: This revision was merged to the branch mainline in revision 1912.
  • Revision ID: john@arbash-meinel.com-20060809155723-9147fe743c052b27
Test that AtomicFile.closed is supported, but deprecated

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
    atomicfile,
25
25
    errors,
26
26
    osutils,
 
27
    symbol_versioning,
27
28
    )
28
29
from bzrlib.tests import TestCaseInTempDir
29
30
 
126
127
        f.commit()
127
128
        st = os.lstat('test')
128
129
        self.assertEqualMode(0666 & ~umask, stat.S_IMODE(st.st_mode))
 
130
 
 
131
    def test_closed(self):
 
132
        local_warnings = []
 
133
        def capture_warnings(msg, cls, stacklevel=None):
 
134
            self.assertEqual(cls, DeprecationWarning)
 
135
            local_warnings.append(msg)
 
136
 
 
137
        method = symbol_versioning.warn
 
138
        try:
 
139
            symbol_versioning.set_warning_method(capture_warnings)
 
140
            f = atomicfile.AtomicFile('test', mode='wb')
 
141
            self.assertEqual(False, f.closed)
 
142
            f.abort()
 
143
            self.assertEqual(True, f.closed)
 
144
 
 
145
            f = atomicfile.AtomicFile('test', mode='wb')
 
146
            f.close()
 
147
            self.assertEqual(True, f.closed)
 
148
 
 
149
            f = atomicfile.AtomicFile('test', mode='wb')
 
150
            f.commit()
 
151
            self.assertEqual(True, f.closed)
 
152
        finally:
 
153
            symbol_versioning.set_warning_method(method)
 
154
 
 
155
        txt = 'AtomicFile.closed deprecated in bzr 0.10'
 
156
        self.assertEqual([txt]*4, local_warnings)