def test_derived():
    patcher = mock.patch.object(Derived, '__bases__', (mock.Mock,))
with patcher:
    patcher.is_local = True
d = Derived()
print(d.foo())
How to mock a base class with python mock library