~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:14:47 UTC
  • mto: This revision was merged to the branch mainline in revision 1912.
  • Revision ID: john@arbash-meinel.com-20060809151447-02e7a4ac00dc7eee
Make AtomicFile not do anything if not supplied a mode, clean up LocalTransport now that we do the right thing for None

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from bzrlib import (
24
24
    atomicfile,
25
25
    errors,
 
26
    osutils,
26
27
    )
27
28
from bzrlib.tests import TestCaseInTempDir
28
29
 
85
86
    def _test_mode(self, mode):
86
87
        if not self.can_sys_preserve_mode():
87
88
            return
88
 
        f = atomicfile.AtomicFile('test', mode='wt', new_mode=mode)
 
89
        f = atomicfile.AtomicFile('test', mode='wb', new_mode=mode)
89
90
        f.write('foo\n')
90
91
        f.commit()
91
92
        st = os.lstat('test')
116
117
        self._test_mode(0400)
117
118
        # Make it read-write again so cleanup doesn't complain
118
119
        os.chmod('test', 0600)
 
120
 
 
121
    def test_no_mode(self):
 
122
        # The default file permissions should be based on umask
 
123
        umask = osutils.get_umask()
 
124
        f = atomicfile.AtomicFile('test', mode='wb')
 
125
        f.write('foo\n')
 
126
        f.commit()
 
127
        st = os.lstat('test')
 
128
        self.assertEqualMode(0666 & ~umask, stat.S_IMODE(st.st_mode))