summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsmiddlek <smiddlek@b1010a0a-674b-0410-b734-77272b80c875>2011-06-06 18:56:52 +0000
committersmiddlek <smiddlek@b1010a0a-674b-0410-b734-77272b80c875>2011-06-06 18:56:52 +0000
commit61f1f11648e177602162680fc1bf0f203b4bd522 (patch)
tree164757bb6d6e31e6d67189fd3583bc325761a0ff
parent92434725a4a4d09f7492eab6fa5d262e0339e361 (diff)
downloadmox-61f1f11648e177602162680fc1bf0f203b4bd522.tar.gz
Patch for Issue 30.
git-svn-id: http://pymox.googlecode.com/svn/trunk@64 b1010a0a-674b-0410-b734-77272b80c875
-rwxr-xr-xmox.py8
1 files 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. :-)