[TIP] Patch

Vincent Kríž vincent.kriz at kamadu.eu
Thu Jan 22 02:36:29 PST 2015


Dear testing-in-python readers!

This is my first mock project:

*** mymodule.py ***

def x(arg1):
    return MyClass(arg1)

class MyClass():
    ...

*** test_mymodule.py ***

import mock
import mymodule

def test_x():
     with mock.patch("mymodule.MyClass") as mock_myclass:
         mymodule.x("test")
         mock_myclass.assert_called_with("test")

When I run nosetests, everything works OK.
When I run "python setup.py test", test failed:

AssertionError: Expected call: MyClass('test')
Not called

Thank you very much for your suggestions!

Best
Vincent



More information about the testing-in-python mailing list