From: Dave Borowitz <[email protected]>

Change-Id: I4808d93cd78d2ace4c30ad0b5e10e3c47cb05978
---
 dulwich/tests/utils.py |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/dulwich/tests/utils.py b/dulwich/tests/utils.py
index f2ae54a..f581a12 100644
--- a/dulwich/tests/utils.py
+++ b/dulwich/tests/utils.py
@@ -57,10 +57,23 @@ def tear_down_repo(repo):
 def make_object(cls, **attrs):
     """Make an object for testing and assign some members.
 
+    This method creates a new subclass to allow arbitrary attribute
+    reassignment, which is not otherwise possible with objects having 
__slots__.
+
     :param attrs: dict of attributes to set on the new object.
     :return: A newly initialized object of type cls.
     """
-    obj = cls()
+
+    class TestObject(cls):
+        """Class that inherits from the given class, but without __slots__.
+
+        Note that classes with __slots__ can't have arbitrary attributes 
monkey-
+        patched in, so this is a class that is exactly the same only with a
+        __dict__ instead of __slots__.
+        """
+        pass
+
+    obj = TestObject()
     for name, value in attrs.iteritems():
         setattr(obj, name, value)
     return obj
-- 
1.7.1


_______________________________________________
Mailing list: https://launchpad.net/~dulwich-users
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~dulwich-users
More help   : https://help.launchpad.net/ListHelp

Reply via email to