Passed
Pull Request — master (#13)
by Ramon
01:39
created

tests.functions.test_get_mro   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 46.67 %

Importance

Changes 0
Metric Value
eloc 19
dl 14
loc 30
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A TestGetMRO.test_get_mro() 3 3 1
A TestGetMRO.test_get_mro_union() 9 9 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 View Code Duplication
class TestGetMRO(TestCase):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
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