Ejemplo n.º 1
0
    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>]")
Ejemplo n.º 2
0
    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, [])
Ejemplo n.º 3
0
    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)])
Ejemplo n.º 4
0
    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, [])
Ejemplo n.º 5
0
    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)])