def test_it_does_not_attach_method_if_attribute_exists(self): class cls: def method(self): pass method = mock.Mock(__name__='method') with self.assertRaises(AttributeError): meta.add_method(cls)(method)
def test_it_attach_method_to_class(self): class cls: pass method = mock.Mock(__name__='method', __doc__='doc string') meta.add_method(cls)(method) self.assertIs(method, cls.method)