I have the following situation:
mixin_foo.py
class Foo:
def doFoo(self):
bar=self.defined_elsewhere()
#....do work
Unit test:
@patch('path_to_mixin_foo.mixin_foo.Foo.defined_elsewhere')
def test_do_foo(self, definedElsewhere)
definedElsewhere.return_value = bar1
self.FooTester.doFoo()
the defined_elsewhere() method is defined in a class that derives from that mixin. However, for development purposes, we are working on mixing_foo.Foo first before integrating it with the class. However, when I try to unit test the doFoo method, the following error is shown by pytest: Attributeerror <....> does not have the attribute 'defined_elsewhere'. Is my patch correct and if there another way to unit test this method? Basically I want to mock out the call/return value of the self.defined_elsewhere so the doFoo method can be tested.