From 61f1f11648e177602162680fc1bf0f203b4bd522 Mon Sep 17 00:00:00 2001 From: smiddlek Date: Mon, 6 Jun 2011 18:56:52 +0000 Subject: Patch for Issue 30. git-svn-id: http://pymox.googlecode.com/svn/trunk@64 b1010a0a-674b-0410-b734-77272b80c875 --- mox.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mox.py b/mox.py index a916e6e..91ab88b 100755 --- a/mox.py +++ b/mox.py @@ -243,7 +243,7 @@ class Mox(object): self._mock_objects = [] self.stubs = stubout.StubOutForTesting() - def CreateMock(self, class_to_mock, attrs={}): + def CreateMock(self, class_to_mock, attrs=None): """Create a new mock object. Args: @@ -255,6 +255,8 @@ class Mox(object): Returns: MockObject that can be used as the class_to_mock would be. """ + if attrs is None: + attrs = {} new_mock = MockObject(class_to_mock, attrs=attrs) self._mock_objects.append(new_mock) return new_mock @@ -521,7 +523,7 @@ class MockAnything: class MockObject(MockAnything, object): """A mock object that simulates the public/protected interface of a class.""" - def __init__(self, class_to_mock, attrs={}): + def __init__(self, class_to_mock, attrs=None): """Initialize a mock object. This determines the methods and properties of the class and stores them. @@ -536,6 +538,8 @@ class MockObject(MockAnything, object): PrivateAttributeError: if a supplied attribute is not public. ValueError: if an attribute would mask an existing method. """ + if attrs is None: + attrs = {} # This is used to hack around the mixin/inheritance of MockAnything, which # is not a proper object (it can be anything. :-) -- cgit v1.2.1