Not sure if it's better or not, but did you consider `with mock.patch_object(server)` instead?