~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-10-22 17:08:00 UTC
  • mfrom: (2922.1.2 binary_read_153493)
  • Revision ID: pqm@pqm.ubuntu.com-20071022170800-egprunbmf7j0hkvm
(John Arbash Meinel, Alexander Belchenko) Fix bug #153493, use O_BINARY when reading files to compute sha1 sum.

Show diffs side-by-side

added added

removed removed

Lines of Context:
277
277
        foo_baz_path = osutils.pathjoin(foo_path, 'baz')
278
278
        self.assertEqual(baz_path, osutils.dereference_path(foo_baz_path))
279
279
 
280
 
 
281
280
    def test_changing_access(self):
282
281
        f = file('file', 'w')
283
282
        f.write('monkey')
299
298
            osutils.make_readonly('dangling')
300
299
            osutils.make_writable('dangling')
301
300
 
302
 
 
303
301
    def test_kind_marker(self):
304
302
        self.assertEqual("", osutils.kind_marker("file"))
305
303
        self.assertEqual("/", osutils.kind_marker(osutils._directory_kind))
1050
1048
        self.assertTrue(isinstance(offset, int))
1051
1049
        eighteen_hours = 18 * 3600
1052
1050
        self.assertTrue(-eighteen_hours < offset < eighteen_hours)
 
1051
 
 
1052
 
 
1053
class TestShaFileByName(TestCaseInTempDir):
 
1054
 
 
1055
    def test_sha_empty(self):
 
1056
        self.build_tree_contents([('foo', '')])
 
1057
        expected_sha = osutils.sha_string('')
 
1058
        self.assertEqual(expected_sha, osutils.sha_file_by_name('foo'))
 
1059
 
 
1060
    def test_sha_mixed_endings(self):
 
1061
        text = 'test\r\nwith\nall\rpossible line endings\r\n'
 
1062
        self.build_tree_contents([('foo', text)])
 
1063
        expected_sha = osutils.sha_string(text)
 
1064
        self.assertEqual(expected_sha, osutils.sha_file_by_name('foo'))