示例#1
0
    def test_compose_mro(self):
        composed = compose_types(C, D)

        assert_equal(composed.f(), C.f())
        assert_equal(composed.g(), D.g())

        assert_equal(composed().delegate(), ('C.delegate', 'D.delegate'))
示例#2
0
    def test_compose_mro(self):
        composed = compose_types(C, D)

        assert_equal(composed.f(), C.f())
        assert_equal(composed.g(), D.g())

        assert_equal(composed().delegate(), ('C.delegate', 'D.delegate'))
    def setUpClass(cls):
        FinalABCMeta = compose_types(FinalMeta, ABCMeta)

        class ABCWithFinal(with_metaclass(FinalABCMeta, object)):
            a = final('ABCWithFinal: a')
            b = 'ABCWithFinal: b'

            @final
            def f(self):
                return 'ABCWithFinal: f'

            def g(self):
                return 'ABCWithFinal: g'

            @abstractmethod
            def h(self):
                raise NotImplementedError('h')

        cls.class_ = ABCWithFinal
示例#4
0
    def setUpClass(cls):
        FinalABCMeta = compose_types(FinalMeta, ABCMeta)

        class ABCWithFinal(with_metaclass(FinalABCMeta, object)):
            a = final("ABCWithFinal: a")
            b = "ABCWithFinal: b"

            @final
            def f(self):
                return "ABCWithFinal: f"

            def g(self):
                return "ABCWithFinal: g"

            @abstractmethod
            def h(self):
                raise NotImplementedError("h")

        cls.class_ = ABCWithFinal
示例#5
0
    def setUpClass(cls):
        FinalABCMeta = compose_types(FinalMeta, ABCMeta)

        class ABCWithFinal(with_metaclass(FinalABCMeta, object)):
            a = final('ABCWithFinal: a')
            b = 'ABCWithFinal: b'

            @final
            def f(self):
                return 'ABCWithFinal: f'

            def g(self):
                return 'ABCWithFinal: g'

            @abstractmethod
            def h(self):
                raise NotImplementedError('h')

        cls.class_ = ABCWithFinal
示例#6
0
    def test_compose(self):
        composed = compose_types(C, D)

        assert_is_subclass(composed, C)
        assert_is_subclass(composed, D)
示例#7
0
 def test_identity(self):
     assert_is(
         compose_types(C),
         C,
         msg='compose_types of a single class should be identity',
     )
示例#8
0
    def test_compose(self):
        composed = compose_types(C, D)

        assert_is_subclass(composed, C)
        assert_is_subclass(composed, D)
示例#9
0
 def test_identity(self):
     assert_is(
         compose_types(C),
         C,
         msg='compose_types of a single class should be identity',
     )