tests.functions.test_get_mro   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A TestGetMRO.test_get_mro_object() 0 3 1
A TestGetMRO.test_get_mro() 0 3 1
A TestGetMRO.test_get_mro_union() 0 9 1
1
import typing
2
from typing import Union
3
from unittest import TestCase
4
5
from typish import get_mro
6
7
8
class A:
9
    ...
10
11
12
class B(A):
13
    ...
14
15
16
class TestGetMRO(TestCase):
17
    def test_get_mro(self):
18
        mro_b = get_mro(B)
19
        self.assertTupleEqual((B, A, object), mro_b)
20
21
    def test_get_mro_union(self):
22
        mro_u = get_mro(Union[int, str])
23
24
        # Below is to stay compatible with Python 3.5+
25
        super_cls = getattr(typing, '_GenericAlias',
26
                            getattr(typing, 'GenericMeta', None))
27
        expected = (typing.Union, super_cls, object)
28
29
        self.assertTupleEqual(expected, mro_u)
30
31
    def test_get_mro_object(self):
32
        mro_b = get_mro(B())
33
        self.assertTupleEqual((B, A, object), mro_b)
34