From 66e31ed3e080e833de08135cc6cfeb74e58452fe Mon Sep 17 00:00:00 2001 From: smiddlek Date: Wed, 12 May 2010 18:19:01 +0000 Subject: 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 --- mox.py | 3 --- mox_test.py | 7 +++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/mox.py b/mox.py index ef28789..0248dbb 100755 --- a/mox.py +++ b/mox.py @@ -423,9 +423,6 @@ class MockAnything: self._description = description self._Reset() - def __str__(self): - return "" % id(self) - def __repr__(self): return '' 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('', 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() -- cgit v1.2.1