summaryrefslogtreecommitdiff
path: root/mox_test.py
diff options
context:
space:
mode:
authorsmiddlek <smiddlek@b1010a0a-674b-0410-b734-77272b80c875>2010-01-08 23:55:35 +0000
committersmiddlek <smiddlek@b1010a0a-674b-0410-b734-77272b80c875>2010-01-08 23:55:35 +0000
commit8d018291d83381d57fe40305ee504861d44f8bcc (patch)
tree507d6e06bac408483a50ef228cb6da8100d1258e /mox_test.py
parent7e0f63eb5f3e955acc0e5d9a228ab932b4a8519b (diff)
downloadmox-8d018291d83381d57fe40305ee504861d44f8bcc.tar.gz
Slightly modified (for style) patch submitted by alan.franzoni to
support setting attributes on a MockObject from a dict supplied to the constructor. This is more efficient than setting attrs by hand. Only public attributes may be set. git-svn-id: http://pymox.googlecode.com/svn/trunk@39 b1010a0a-674b-0410-b734-77272b80c875
Diffstat (limited to 'mox_test.py')
-rwxr-xr-xmox_test.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/mox_test.py b/mox_test.py
index bf806f6..e1626d6 100755
--- a/mox_test.py
+++ b/mox_test.py
@@ -1030,6 +1030,20 @@ class MockObjectTest(unittest.TestCase):
self.assertEquals(['a', 'b'], [x for x in dummy])
dummy._Verify()
+ def testInstantiationWithAdditionalAttributes(self):
+ mock_object = mox.MockObject(TestClass, attrs={"attr1": "value"})
+ self.assertEquals(mock_object.attr1, "value")
+
+ def testCantOverrideMethodsWithAttributes(self):
+ self.assertRaises(ValueError, mox.MockObject, TestClass,
+ attrs={"ValidCall": "value"})
+
+ def testCantMockNonPublicAttributes(self):
+ self.assertRaises(mox.PrivateAttributeError, mox.MockObject, TestClass,
+ attrs={"_protected": "value"})
+ self.assertRaises(mox.PrivateAttributeError, mox.MockObject, TestClass,
+ attrs={"__private": "value"})
+
class MoxTest(unittest.TestCase):
"""Verify Mox works correctly."""