How to use the singledispatch._c3_mro function in singledispatch

To help you get started, we’ve selected a few singledispatch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ambv / singledispatch / test_singledispatch.py View on Github external
def test_c3_abc(self):
        c = collections
        mro = functools._c3_mro
        class A(object):
            pass
        class B(A):
            def __len__(self):
                return 0   # implies Sized
        @c.Container.register
        class C(object):
            pass
        class D(object):
            pass   # unrelated
        class X(D, C, B):
            def __call__(self):
                pass   # implies Callable
        expected = [X, c.Callable, D, C, c.Container, B, c.Sized, A, object]
        for abcs in permutations([c.Sized, c.Callable, c.Container]):
            self.assertEqual(mro(X, abcs=abcs), expected)

singledispatch

Backport functools.singledispatch to older Pythons.

MIT
Latest version published 1 year ago

Package Health Score

67 / 100
Full package analysis