Rev 2924: Add tests for sha_file_by_name. in http://bzr.arbash-meinel.com/branches/bzr/0.92-dev/binary_read_153493

John Arbash Meinel john at arbash-meinel.com
Mon Oct 22 17:03:52 BST 2007


At http://bzr.arbash-meinel.com/branches/bzr/0.92-dev/binary_read_153493

------------------------------------------------------------
revno: 2924
revision-id:john at arbash-meinel.com-20071022160311-o9ghjovhh6s734n3
parent: john at arbash-meinel.com-20071022155447-ev3m0pvsmeel6nge
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: binary_read_153493
timestamp: Mon 2007-10-22 11:03:11 -0500
message:
  Add tests for sha_file_by_name.
modified:
  bzrlib/tests/test_osutils.py   test_osutils.py-20051201224856-e48ee24c12182989
-------------- next part --------------
=== modified file 'bzrlib/tests/test_osutils.py'
--- a/bzrlib/tests/test_osutils.py	2007-09-25 08:14:12 +0000
+++ b/bzrlib/tests/test_osutils.py	2007-10-22 16:03:11 +0000
@@ -277,7 +277,6 @@
         foo_baz_path = osutils.pathjoin(foo_path, 'baz')
         self.assertEqual(baz_path, osutils.dereference_path(foo_baz_path))
 
-
     def test_changing_access(self):
         f = file('file', 'w')
         f.write('monkey')
@@ -299,7 +298,6 @@
             osutils.make_readonly('dangling')
             osutils.make_writable('dangling')
 
-
     def test_kind_marker(self):
         self.assertEqual("", osutils.kind_marker("file"))
         self.assertEqual("/", osutils.kind_marker(osutils._directory_kind))
@@ -1050,3 +1048,17 @@
         self.assertTrue(isinstance(offset, int))
         eighteen_hours = 18 * 3600
         self.assertTrue(-eighteen_hours < offset < eighteen_hours)
+
+
+class TestShaFileByName(TestCaseInTempDir):
+
+    def test_sha_empty(self):
+        self.build_tree_contents([('foo', '')])
+        expected_sha = osutils.sha_string('')
+        self.assertEqual(expected_sha, osutils.sha_file_by_name('foo'))
+
+    def test_sha_mixed_endings(self):
+        text = 'test\r\nwith\nall\rpossible line endings\r\n'
+        self.build_tree_contents([('foo', text)])
+        expected_sha = osutils.sha_string(text)
+        self.assertEqual(expected_sha, osutils.sha_file_by_name('foo'))



More information about the bazaar-commits mailing list