@contextmanager
def patch_client(target, mock_client=None):
 with mock.patch(target) as client_getter:
  client = (mock_client or MockBox())
  client_getter.return_value = client
  (yield client)

@ contextmanager def patch_client ( target , mock_client = None ) : with mock . patch ( target ) as client_getter : client = ( mock_client or MockBox ( ) ) client_getter . return_value = client ( yield client )
patches a function that returns a dropboxclient .