TestGetMRO.test_get_mro_object()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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