~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_atomicfile.py

  • Committer: Martin Pool
  • Date: 2009-08-20 04:53:23 UTC
  • mto: This revision was merged to the branch mainline in revision 4632.
  • Revision ID: mbp@sourcefrog.net-20090820045323-4hsicfa87pdq3l29
Correction to xdg_cache_dir and add a simple test

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Basic tests for AtomicFile"""
18
18
 
26
26
    osutils,
27
27
    symbol_versioning,
28
28
    )
29
 
from bzrlib.tests import TestCaseInTempDir
 
29
from bzrlib.tests import TestCaseInTempDir, TestSkipped
30
30
 
31
31
 
32
32
class TestAtomicFile(TestCaseInTempDir):
68
68
 
69
69
        # close is re-entrant safe
70
70
        f.close()
71
 
        
 
71
 
72
72
    def test_text_mode(self):
73
73
        f = atomicfile.AtomicFile('test', mode='wt')
74
74
        f.write('foo\n')
86
86
 
87
87
    def _test_mode(self, mode):
88
88
        if not self.can_sys_preserve_mode():
89
 
            return
 
89
            raise TestSkipped("This test cannot be run on your platform")
90
90
        f = atomicfile.AtomicFile('test', mode='wb', new_mode=mode)
91
91
        f.write('foo\n')
92
92
        f.commit()
93
93
        st = os.lstat('test')
94
94
        self.assertEqualMode(mode, stat.S_IMODE(st.st_mode))
95
95
 
96
 
    def test_mode_02666(self):
97
 
        self._test_mode(02666)
98
 
 
99
96
    def test_mode_0666(self):
100
97
        self._test_mode(0666)
101
98