diff options
author | smiddlek <smiddlek@b1010a0a-674b-0410-b734-77272b80c875> | 2010-05-12 18:19:01 +0000 |
---|---|---|
committer | smiddlek <smiddlek@b1010a0a-674b-0410-b734-77272b80c875> | 2010-05-12 18:19:01 +0000 |
commit | 66e31ed3e080e833de08135cc6cfeb74e58452fe (patch) | |
tree | 4dc6a889d7a622705a31573504158b3871420d79 | |
parent | 18af5e8f19ae7fe604b00bd2e1441290b899f6f4 (diff) | |
download | mox-66e31ed3e080e833de08135cc6cfeb74e58452fe.tar.gz |
MoxAnything should not implement the method __str__, otherwise callers won't be
able to mock __str__ calls.
git-svn-id: http://pymox.googlecode.com/svn/trunk@48 b1010a0a-674b-0410-b734-77272b80c875
-rwxr-xr-x | mox.py | 3 | ||||
-rwxr-xr-x | mox_test.py | 7 |
2 files changed, 7 insertions, 3 deletions
@@ -423,9 +423,6 @@ class MockAnything: self._description = description self._Reset() - def __str__(self): - return "<MockAnything instance at %s>" % id(self) - def __repr__(self): return '<MockAnything instance>' diff --git a/mox_test.py b/mox_test.py index 9849339..58142f6 100755 --- a/mox_test.py +++ b/mox_test.py @@ -490,6 +490,13 @@ class MockAnythingTest(unittest.TestCase): """Calling repr on a MockAnything instance must work.""" self.assertEqual('<MockAnything instance>', repr(self.mock_object)) + def testCanMockStr(self): + self.mock_object.__str__().AndReturn("foo"); + self.mock_object._Replay() + actual = str(self.mock_object) + self.mock_object._Verify(); + self.assertEquals("foo", actual) + def testSetupMode(self): """Verify the mock will accept any call.""" self.mock_object.NonsenseCall() |