* Refactor some of dulwich.tests.compat.server_utils. (Dave Borowitz)
+ * Allow overwriting id property of objects in test utils. (Dave Borowitz)
+
API CHANGES
* ObjectStore.iter_tree_contents now walks contents in depth-first, sorted
self.assertEqual(c.author_timezone, 0)
self.assertEqual(c.message, 'Merge ../b\n')
+ def test_stub_sha(self):
+ sha = '5' * 40
+ c = make_commit(id=sha, message='foo')
+ self.assertTrue(isinstance(c, Commit))
+ self.assertEqual(sha, c.id)
+ self.assertNotEqual(sha, c._make_sha())
+
class ShaFileCheckTests(TestCase):
import tempfile
import time
-from dulwich.objects import Commit
+from dulwich.objects import (
+ FixedSha,
+ Commit,
+ )
from dulwich.repo import Repo
obj = TestObject()
for name, value in attrs.iteritems():
- setattr(obj, name, value)
+ if name == 'id':
+ # id property is read-only, so we overwrite sha instead.
+ sha = FixedSha(value)
+ obj.sha = lambda: sha
+ else:
+ setattr(obj, name, value)
return obj