When trying to use MockAnything in a recorded method call, failures will be unprintable because MockAnything will record the repr call and raise an exception.
Using this test code:
mock = mox.Mox () mock_qs = mock.CreateMockAnything () mock_qs.all ().AndReturn (mock_qs) mock.ReplayAll () mock.VerifyAll ()
Causes this (rather unhelpful) failure:
Traceback (most recent call last): File "tests/test_gallery.py", line 47, in test_already_contains mock.VerifyAll () File "/usr/lib/python2.5/site-packages/mox-0.5.0-py2.5.egg/mox.py", line 197, in VerifyAll mock_obj._Verify() File "/usr/lib/python2.5/site-packages/mox-0.5.0-py2.5.egg/mox.py", line 344, in _Verify raise ExpectedMethodCallsError(self._expected_calls_queue) ExpectedMethodCallsError: <unprintable ExpectedMethodCallsError object>
Comment #1
Posted on Nov 12, 2008 by Helpful RhinoIs there a workaround while this is being fixed to know what really failed?
Comment #2
Posted on Feb 18, 2009 by Grumpy OxThis is a rather naive fix (it will mess up actual attempts to mock str and repr) but it's been helpful for me in terms of debugging. In the MockAnything class definition (mox.py ln 265) add the following:
def str(self): return ""
def repr(self): return self.str()
Comment #3
Posted on Apr 29, 2009 by Swift KangarooAttached is a patch against r28 with agoartim's change and a test that exercises it.
Comment #4
Posted on May 5, 2009 by Massive PandaFixed in revision 29. Thanks for the patch! :)
Status: Fixed
Labels:
Type-Defect
Priority-Medium