| Total Complexity | 3 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Changes | 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 |