Fix parsing from file-like objects.
[jelmer/dulwich-libgit2.git] / dulwich / tests / test_objects.py
index 27a9fa1555e565932a6355682aa463ed1a4b19ed..519f5f78c485bbd6a3c5c9f46f8fcb4cb5223cfe 100644 (file)
@@ -22,6 +22,7 @@
 # TODO: Round-trip parse-serialize-parse and serialize-parse-serialize tests.
 
 
+from cStringIO import StringIO
 import datetime
 import os
 import stat
@@ -147,6 +148,13 @@ class BlobReadTests(TestCase):
         self.assertEqual(b.data, string)
         self.assertEqual(b.sha().hexdigest(), b_sha)
 
+    def test_legacy_from_file(self):
+        b1 = Blob.from_string("foo")
+        b_raw = b1.as_legacy_object()
+        open('x', 'w+').write(b_raw)
+        b2 = b1.from_file(StringIO(b_raw))
+        self.assertEquals(b1, b2)
+
     def test_chunks(self):
         string = 'test 5\n'
         b = Blob.from_string(string)