Commits

Andrew Godwin  committed cf1e932

Text fixing up, and bugfix to SVN1 svndiff code.

  • Participants
  • Parent commits a6b2d5e

Comments (0)

Files changed (4)

File heechee/svndiff.py

         integer_length = 0
     # Read the data and possible decode it
     data = handle.read(current_length - integer_length)
-    #print repr(data), len(data), original_length
     # If the length is different, zlib decode it
     if use_zlib and len(data) != original_length:
-        data = zlib.decompress(data[1:])
+        data = zlib.decompress(data)
     return data
 
 
 def undiff(source, diff):
+    "Takes a source file-like object and a diff as a file-like object."
     
     # Initialise the target
     target = StringIO()

File heechee/tests/__init__.py

+
+import unittest
+
+from heechee.tests.mercurial import MercurialTests
+from heechee.tests.svndiff import SvnDiffTests
+
+if __name__ == '__main__':
+    unittest.main()

File heechee/tests/mercurial.py

 """
 
 import unittest
-from heechee.base import HeecheeTest
+from heechee.tests.base import HeecheeTest
 
-class BasicMercurialTests(HeecheeTest):
+class MercurialTests(HeecheeTest):
     
     def init_repo(self):
         self.source_cmds([

File heechee/tests/svndiff.py

 import unittest
 
 from heechee.svndiff import StringIO, make_cheap_diff, undiff
-from heechee.base import HeecheeTest
+from heechee.tests.base import HeecheeTest
 
 class SvnDiffTests(HeecheeTest):
-    pass
+    
+    # This doesn't touch a repo, so no special setup.
+    def setUp(self): pass
+    def tearDown(self): pass
+    
+    def test_no_zlib(self):
+        self.assert_equal(
+            "hello world",
+            undiff(StringIO(""), StringIO(make_cheap_diff("hello world", use_zlib=False))),
+        )
+    
+    def test_zlib(self):
+        self.assert_equal(
+            "hello world",
+            undiff(StringIO(""), StringIO(make_cheap_diff("hello world", use_zlib=True))),
+        )
+    
+    def test_empty_no_zlib(self):
+        self.assert_equal(
+            "",
+            undiff(StringIO(""), StringIO(make_cheap_diff("", use_zlib=False))),
+        )
+    
+    def test_empty_zlib(self):
+        self.assert_equal(
+            "",
+            undiff(StringIO(""), StringIO(make_cheap_diff("", use_zlib=True))),
+        )