示例#1
0
def test_concat_interfaces():
    cls = astroid.extract_node('''
        class IMachin: pass

        class Correct2:
            """docstring"""
            __implements__ = (IMachin,)

        class BadArgument:
            """docstring"""
            __implements__ = (IMachin,)

        class InterfaceCanNowBeFound: #@
            """docstring"""
            __implements__ = BadArgument.__implements__ + Correct2.__implements__
    ''')
    interfaces = inspector.interfaces(cls)
    assert [i.name for i in interfaces] == ["IMachin"]
    def test_concat_interfaces(self):
        cls = astroid.extract_node('''
            class IMachin: pass

            class Correct2:
                """docstring"""
                __implements__ = (IMachin,)

            class BadArgument:
                """docstring"""
                __implements__ = (IMachin,)

            class InterfaceCanNowBeFound: #@
                """docstring"""
                __implements__ = BadArgument.__implements__ + Correct2.__implements__
        ''')
        interfaces = inspector.interfaces(cls)
        self.assertEqual([i.name for i in interfaces], ['IMachin'])
示例#3
0
    def test_concat_interfaces(self):
        cls = test_utils.extract_node('''
            class IMachin: pass

            class Correct2:
                """docstring"""
                __implements__ = (IMachin,)

            class BadArgument:
                """docstring"""
                __implements__ = (IMachin,)

            class InterfaceCanNowBeFound: #@
                """docstring"""
                __implements__ = BadArgument.__implements__ + Correct2.__implements__
        ''')
        interfaces = inspector.interfaces(cls)
        self.assertEqual([i.name for i in interfaces], ['IMachin'])
def test_interfaces():
    module = astroid.parse('''
    class Interface(object): pass
    class MyIFace(Interface): pass
    class AnotherIFace(Interface): pass
    class Concrete0(object):
        __implements__ = MyIFace
    class Concrete1:                     
        __implements__ = (MyIFace, AnotherIFace)
    class Concrete2:
        __implements__ = (MyIFace, AnotherIFace)
    class Concrete23(Concrete1): pass
    ''')

    for klass, interfaces in (('Concrete0', ['MyIFace']),
                              ('Concrete1', ['MyIFace', 'AnotherIFace']),
                              ('Concrete2', ['MyIFace', 'AnotherIFace']),
                              ('Concrete23', ['MyIFace', 'AnotherIFace'])):
        klass = module[klass]
        assert [i.name for i in inspector.interfaces(klass)] == interfaces
def test_interfaces():
    module = astroid.parse('''
    class Interface(object): pass
    class MyIFace(Interface): pass
    class AnotherIFace(Interface): pass
    class Concrete0(object):
        __implements__ = MyIFace
    class Concrete1:                     
        __implements__ = (MyIFace, AnotherIFace)
    class Concrete2:
        __implements__ = (MyIFace, AnotherIFace)
    class Concrete23(Concrete1): pass
    ''')

    for klass, interfaces in (('Concrete0', ['MyIFace']),
                              ('Concrete1', ['MyIFace', 'AnotherIFace']),
                              ('Concrete2', ['MyIFace', 'AnotherIFace']),
                              ('Concrete23', ['MyIFace', 'AnotherIFace'])):
        klass = module[klass]
        assert [i.name for i in inspector.interfaces(klass)] == interfaces
示例#6
0
def test_interfaces():
    module = astroid.parse("""
    class Interface(object): pass
    class MyIFace(Interface): pass
    class AnotherIFace(Interface): pass
    class Concrete0(object):
        __implements__ = MyIFace
    class Concrete1:
        __implements__ = (MyIFace, AnotherIFace)
    class Concrete2:
        __implements__ = (MyIFace, AnotherIFace)
    class Concrete23(Concrete1): pass
    """)

    for klass, interfaces in (
        ("Concrete0", ["MyIFace"]),
        ("Concrete1", ["MyIFace", "AnotherIFace"]),
        ("Concrete2", ["MyIFace", "AnotherIFace"]),
        ("Concrete23", ["MyIFace", "AnotherIFace"]),
    ):
        klass = module[klass]
        assert [i.name for i in inspector.interfaces(klass)] == interfaces
    def test_interfaces(self):
        module = astroid.parse(
            """
        class Interface(object): pass
        class MyIFace(Interface): pass
        class AnotherIFace(Interface): pass
        class Concrete0(object):
            __implements__ = MyIFace
        class Concrete1:                     
            __implements__ = (MyIFace, AnotherIFace)
        class Concrete2:
            __implements__ = (MyIFace, AnotherIFace)
        class Concrete23(Concrete1): pass
        """
        )

        for klass, interfaces in (
            ("Concrete0", ["MyIFace"]),
            ("Concrete1", ["MyIFace", "AnotherIFace"]),
            ("Concrete2", ["MyIFace", "AnotherIFace"]),
            ("Concrete23", ["MyIFace", "AnotherIFace"]),
        ):
            klass = module[klass]
            self.assertEqual([i.name for i in inspector.interfaces(klass)], interfaces)