MarkBerlin78 / pymox

Automatically exported from code.google.com/p/pymox
Apache License 2.0
0 stars 0 forks source link

Mox isn't playing well with nosetests on failures - OSX #6

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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

Original issue reported on code.google.com by K.Adam.C...@gmail.com on 6 Mar 2009 at 3:10

GoogleCodeExporter commented 9 years ago
This 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

Original comment by K.Adam.C...@gmail.com on 6 Mar 2009 at 12:02

GoogleCodeExporter commented 9 years ago

Original comment by smidd...@gmail.com on 20 Mar 2009 at 5:04

GoogleCodeExporter commented 9 years ago
I 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()

Original comment by pengyu...@gmail.com on 31 Mar 2012 at 10:33