I want to mock the default argument in a class constructor:
class A (object):
def __init__(self, connection=DefaultConnection()):
self.connection = connection
I want to mock DefaultConnection
in my unittests, but it doesn't work when passed in as a default value.
You can use patch to patch the module, and then you can set the return value as a Mock.