What steps will reproduce the problem? import unittest import mox
class Foo(object):
@classmethod
def some_method(cls):
pass
class TestFoo(mox.MoxTestBase):
def setUp(self):
super(TestFoo, self).setUp()
self.mox.StubOutWithMock(Foo, 'some_method')
def test_some_method_is_called(self):
Foo.some_method()
self.mox.ReplayAll()
if name == 'main': unittest.main()
What do you see? python test.py
F
FAIL: test_some_method_is_called (main.TestFoo)
Traceback (most recent call last): File "/Users/kparmar/sources/pymox/mox.py", line 2120, in new_method mox_obj.VerifyAll() File "/Users/kparmar/sources/pymox/mox.py", line 318, in VerifyAll mock_obj._Verify() File "/Users/kparmar/sources/pymox/mox.py", line 559, in _Verify raise ExpectedMethodCallsError(self._expected_calls_queue) ExpectedMethodCallsError: Verify: Expected methods never called: 0. instancemethod.call() -> None
Please provide any additional information below. With the changes made from the patch, the output is - python test.py
F
FAIL: test_some_method_is_called (main.TestFoo)
Traceback (most recent call last): File "/Users/kparmar/sources/pymox/mox.py", line 2120, in new_method mox_obj.VerifyAll() File "/Users/kparmar/sources/pymox/mox.py", line 318, in VerifyAll mock_obj._Verify() File "/Users/kparmar/sources/pymox/mox.py", line 559, in _Verify raise ExpectedMethodCallsError(self._expected_calls_queue) ExpectedMethodCallsError: Verify: Expected methods never called: 0. Foo.some_method.call() -> None
Comment #1
Posted on Nov 18, 2012 by Massive HippoComment deleted
Comment #2
Posted on Nov 18, 2012 by Massive HippoMy earlier patch did not account for instance methods. Attached an updated patch.
Here's how I tested it -
import unittest import mox
class Foo(object):
@classmethod
def cls_method(cls):
pass
def ins_method(self):
pass
class TestFoo(mox.MoxTestBase):
def setUp(self):
super(TestFoo, self).setUp()
self.mox.StubOutWithMock(Foo, 'cls_method')
self.foo = Foo()
self.mox.StubOutWithMock(self.foo, 'ins_method')
def test_cls_method_is_called(self):
Foo.cls_method()
self.mox.ReplayAll()
def test_ins_method_is_called(self):
self.foo.ins_method()
self.mox.ReplayAll()
if name == 'main': unittest.main()
Output before - python test.py
FF
FAIL: test_cls_method_is_called (main.TestFoo)
Traceback (most recent call last): File "/Users/kparmar/sources/pymox/mox.py", line 2123, in new_method mox_obj.VerifyAll() File "/Users/kparmar/sources/pymox/mox.py", line 318, in VerifyAll mock_obj._Verify() File "/Users/kparmar/sources/pymox/mox.py", line 559, in _Verify raise ExpectedMethodCallsError(self._expected_calls_queue) ExpectedMethodCallsError: Verify: Expected methods never called: 0. instancemethod.call() -> None
======================================================================
FAIL: test_ins_method_is_called (main.TestFoo)
Traceback (most recent call last): File "/Users/kparmar/sources/pymox/mox.py", line 2123, in new_method mox_obj.VerifyAll() File "/Users/kparmar/sources/pymox/mox.py", line 318, in VerifyAll mock_obj._Verify() File "/Users/kparmar/sources/pymox/mox.py", line 559, in _Verify raise ExpectedMethodCallsError(self._expected_calls_queue) ExpectedMethodCallsError: Verify: Expected methods never called: 0. instancemethod.call() -> None
Output after - python test.py
FF
FAIL: test_cls_method_is_called (main.TestFoo)
Traceback (most recent call last): File "/Users/kparmar/sources/pymox/mox.py", line 2123, in new_method mox_obj.VerifyAll() File "/Users/kparmar/sources/pymox/mox.py", line 318, in VerifyAll mock_obj._Verify() File "/Users/kparmar/sources/pymox/mox.py", line 559, in _Verify raise ExpectedMethodCallsError(self._expected_calls_queue) ExpectedMethodCallsError: Verify: Expected methods never called: 0. Foo.cls_method.call() -> None
======================================================================
FAIL: test_ins_method_is_called (main.TestFoo)
Traceback (most recent call last): File "/Users/kparmar/sources/pymox/mox.py", line 2123, in new_method mox_obj.VerifyAll() File "/Users/kparmar/sources/pymox/mox.py", line 318, in VerifyAll mock_obj._Verify() File "/Users/kparmar/sources/pymox/mox.py", line 559, in _Verify raise ExpectedMethodCallsError(self._expected_calls_queue) ExpectedMethodCallsError: Verify: Expected methods never called: 0. Foo.ins_method.call() -> None
Comment #3
Posted on Nov 29, 2012 by Massive HippoHaven't seen any progress on this. Do you need more information?
Status: New
Labels:
Type-Defect
Priority-Medium