mock objects in python are not working on Jenkins? -
i have method, needs mocked dependend on params. e.g.:
mock_obj.method('param1').get()
returns 10
mock_obj.method('param2').get()
returns '~/programs'
etc.
i using side_effect:
def method_mock(*args, **kwargs): param_name = args[0] pref = magicmock() pref.get.return_value = { 'param1': 10, 'param2': "~/programs" }[param_name] return pref mock_obj = magicmock() mock_obj.method = magicmock(side_effect = method_mock)
then call mock:
>>> mock_obj.method('param1').get() 10 >>> mock_obj.method('param2').get() '~/programs'
everything working fine on machine. when run tests (using nosetests) on ci server(jenkins) this:
>>> mock_obj.method('param1').get() <magicmock name='mock_obj.method().get()' id='22379152'> >>> mock_obj.method('param2').get() <magicmock name='mock_obj.method().get()' id='22379152'>
however when run above code console (on ci machine) working fine...
edit:
after whole day found solution. problem nosetests. when using 1 command run tests got issue described above:
nosetests --with-xunit --all-modules
when run each test separately...everything working:
nosetests --with-xunit test_integration1 nosetests --with-xunit test_integration2 nosetests --with-xunit test_integration3 nosetests --with-xunit test_integration4
any idea how fix able run tests 1 command?
Comments
Post a Comment