I'm not sure if this is a nose problem or a mox problem; but I thought I would share it here.
The problem is the readability of the error. The error is being thrown because the mock isn't matching, which is good. However, the error gives no clue as to what failed. In OSX, I have no idea what mock getting the wrong data sent to it.
What steps will reproduce the problem? 1. Create a failing test that use mox 2. Run the tests with nose
What is the expected output? What do you see instead? I expect to see output like:
======================================================================
FAIL: test_failing_hello (mymodule_test.TestHello)
Traceback (most recent call last): File "build/bdist.linux-i686/egg/mox.py", line 1374, in new_method func(self, *args, **kwargs) File "/home/pope/Documents/code/gist-74723/mymodule_test.py", line 13, in test_failing_hello mymodule.hello() File "/home/pope/Documents/code/gist-74723/mymodule.py", line 6, in hello return repeater("Hello") File "build/bdist.linux-i686/egg/mox.py", line 562, in call expected_method = self._VerifyMethodCall() File "build/bdist.linux-i686/egg/mox.py", line 608, in _VerifyMethodCall raise UnexpectedMethodCallError(self, expected) UnexpectedMethodCallError: Unexpected method call: call('Hello') -> None. Expecting: call('World') -> 'HelloWorld'
However, I am seeing this:
======================================================================
ERROR: test_failing_hello (mymodule_test.TestHello)
Traceback (most recent call last): File "/Users/pope/Desktop/mox_test/nose-0.10.4-py2.6.egg/nose/case.py", line 131, in run self.runTest(result) File "/Users/pope/Desktop/mox_test/nose-0.10.4-py2.6.egg/nose/case.py", line 149, in runTest test(result) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/unittest.py", line 300, in call return self.run(*args, **kwds) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/unittest.py", line 282, in run result.addFailure(self, self._exc_info()) File "/Users/pope/Desktop/mox_test/nose-0.10.4-py2.6.egg/nose/proxy.py", line 131, in addFailure formatted = plugins.formatFailure(self.test, err) File "/Users/pope/Desktop/mox_test/nose-0.10.4-py2.6.egg/nose/plugins/manager.py", line 81, in call return self.call(*arg, **kw) File "/Users/pope/Desktop/mox_test/nose-0.10.4-py2.6.egg/nose/plugins/manager.py", line 119, in chain result = meth(*arg, **kw) File "/Users/pope/Desktop/mox_test/nose-0.10.4-py2.6.egg/nose/plugins/failuredetail.py", line 40, in formatFailure tbinfo = inspect_traceback(tb) File "/Users/pope/Desktop/mox_test/nose-0.10.4-py2.6.egg/nose/inspector.py", line 33, in inspect_traceback inspect_lines, mark_line = find_inspectable_lines(lines, exc_line) File "/Users/pope/Desktop/mox_test/nose-0.10.4-py2.6.egg/nose/inspector.py", line 122, in find_inspectable_lines home = lines[pos] TypeError: 'NoneType' object is unsubscriptable
What version of the product are you using? On what operating system? I'm using Mox 0.5.0, Nose 0.10.4, Python 2.5 and 2.6, Mac OS X 10.5.6 Intel
Please provide any additional information below. I set up a REALLY dumb test case at http://gist.github.com/74723
Comment #1
Posted on Mar 6, 2009 by Helpful RhinoThis issue is actually a problem with nose. Details can be found in http://code.google.com/p/python- nose/issues/detail?id=236
The fix is in the trunk of the nose project
Please close this. Thank you
Comment #2
Posted on Mar 20, 2009 by Massive Panda(No comment was entered for this change.)
Comment #3
Posted on Mar 31, 2012 by Happy ElephantI got the same error(mox-0.5.3-py2.7):
FAIL: testGetCf (main.TestApiServer)
Traceback (most recent call last): File "test_api_server.py", line 58, in testGetCf api_server.get_cf("testcf") File "/home/pyw/work/demux/server/api_server.py", line 132, in get_cf cfs[cf_str] = pycassa.ColumnFamily(data_db, cf_str) File "/usr/local/lib/python2.7/dist-packages/mox-0.5.3-py2.7.egg/mox.py", line 765, in call return mock_method(*params, **named_params) File "/usr/local/lib/python2.7/dist-packages/mox-0.5.3-py2.7.egg/mox.py", line 1002, in call expected_method = self._VerifyMethodCall() File "/usr/local/lib/python2.7/dist-packages/mox-0.5.3-py2.7.egg/mox.py", line 1060, in _VerifyMethodCall raise UnexpectedMethodCallError(self, expected) UnexpectedMethodCallError: Unexpected method call. unexpected:- expected:+ - ColumnFamily.call('db', 'testcf') -> None + ColumnFamily.call() -> <main.ColumnFamilyMox instance at 0x919d2ec>
my code: self.mox.StubOutWithMock(pycassa, 'ColumnFamily') pycassa.ColumnFamily().AndReturn(ColumnFamilyMox()) pycassa.ColumnFamily('1','2').AndReturn(ColumnFamilyMox())
self.mox.ReplayAll()
api_server.data_db = 'db'
api_server.get_cf("testcf")
self.mox.VerifyAll()
Status: Invalid
Labels:
Type-Defect
Priority-Medium