Exemple #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>]")
Exemple #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, [])
Exemple #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)])
Exemple #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, [])
Exemple #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)])