def test_method_str(self): class Foo(): def bar(self, baz, qux=None): """This is a method""" method = utils.MethodInspector(Foo().bar) self.assertEqual(str(method), "bar baz=<baz> [qux=<qux>]")
def test_method_without_args(self): def foo(): """This is a method""" method = utils.MethodInspector(foo) self.assertEqual(method.required_args, []) self.assertEqual(method.optional_args, [])
def test_method_with_optional_args(self): def foo(bar, baz=1): """This is a method""" method = utils.MethodInspector(foo) self.assertEqual(method.required_args, ['bar']) self.assertEqual(method.optional_args, [('baz', 1)])
def test_instance_method_without_args(self): class Foo(): def bar(self): """This is a method""" method = utils.MethodInspector(Foo().bar) self.assertEqual(method.required_args, []) self.assertEqual(method.optional_args, [])
def test_instance_method_with_optional_args(self): class Foo(): def bar(self, baz, qux=2): """This is a method""" method = utils.MethodInspector(Foo().bar) self.assertEqual(method.required_args, ['baz']) self.assertEqual(method.optional_args, [('qux', 2)])