test_easy_unpack   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 80 %

Importance

Changes 0
Metric Value
eloc 20
dl 24
loc 30
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A Tests.test_Basics() 3 3 2
A Tests.test_Extra() 3 3 2

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 unittest
2
3
from easy_unpack import easy_unpack
4
5
6 View Code Duplication
class Tests(unittest.TestCase):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7
    TESTS = {
8
        "Basics": [
9
            {"input": [1, 2, 3, 4, 5, 6, 7, 9], "answer": (1, 3, 7)},
10
            {"input": [1, 1, 1, 1], "answer": (1, 1, 1)},
11
            {"input": [6, 3, 7], "answer": (6, 7, 3)},
12
        ],
13
        "Extra": [
14
            {"input": [30, 40, 100], "answer": (30, 100, 40)},
15
            {"input": [5, 5, 5, 5, 5, 5], "answer": (5, 5, 5)},
16
        ],
17
    }
18
19
    def test_Basics(self):
20
        for i in self.TESTS['Basics']:
21
            assert easy_unpack(i['input']) == i['answer']
22
23
    def test_Extra(self):
24
        for i in self.TESTS['Extra']:
25
            assert easy_unpack(i['input']) == i['answer']
26
27
28
if __name__ == "__main__":  # pragma: no cover
29
    unittest.main()
30