Ejemplo n.º 1
0
    def test_bound_method_unbound(self):
        python_string = textwrap.dedent("""
        class Cls(object):
            def func(arg1):
                pass
        """)

        node = parser.get_ast_node_from_string(python_string)
        methods = [
            method for cls in parser.get_module_classes(node)
            for method in parser.get_class_methods(cls)
            if parser.is_class_method_bound(method)
        ]
        result = [method.name for method in methods]

        self.assertEmpty(result)
Ejemplo n.º 2
0
    def test_bound_method_non_default_name(self):
        python_string = textwrap.dedent("""
        class Cls(object):
            def func(this, arg1):
                pass
        """)

        node = parser.get_ast_node_from_string(python_string)
        methods = [
            method for cls in parser.get_module_classes(node)
            for method in parser.get_class_methods(cls)
            if parser.is_class_method_bound(method, arg_name="this")
        ]
        result = [method.name for method in methods]
        expected = ["func"]

        self.assertCountEqual(result, expected)