from mock import patch
from foo import printFoo

@patch('foo.returnBar')
def test_printFoo(mockBar):
    mockBar.return_value = 'Foo'
printFoo()
test_printFoo()
How to mock a function defined in a module of a package?