| Total Complexity | 4 |
| Total Lines | 41 |
| Duplicated Lines | 75.61 % |
| Changes | 0 | ||
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 counting_tiles import checkio |
||
| 4 | |||
| 5 | |||
| 6 | View Code Duplication | class Tests(unittest.TestCase): |
|
|
|
|||
| 7 | TESTS = { |
||
| 8 | "Basics": [ |
||
| 9 | {"input": 2, "answer": [4, 12]}, |
||
| 10 | {"input": 3, "answer": [16, 20]}, |
||
| 11 | {"input": 2.1, "answer": [4, 20]}, |
||
| 12 | {"input": 2.5, "answer": [12, 20]}, |
||
| 13 | {"input": 1, "answer": [0, 4]}, |
||
| 14 | {"input": 4, "answer": [32, 28]}, |
||
| 15 | {"input": 0.5, "answer": [0, 4]}, |
||
| 16 | {"input": 3.5, "answer": [24, 28]}, |
||
| 17 | {"input": 3.8, "answer": [32, 28]}, |
||
| 18 | ], |
||
| 19 | "Extra": [ |
||
| 20 | {"input": 1.1, "answer": [0, 12]}, |
||
| 21 | {"input": 2.2, "answer": [4, 20]}, |
||
| 22 | {"input": 3.3, "answer": [24, 28]}, |
||
| 23 | {"input": 0.9, "answer": [0, 4]}, |
||
| 24 | {"input": 2.7, "answer": [12, 20]}, |
||
| 25 | {"input": 3.4, "answer": [24, 28]}, |
||
| 26 | {"input": 0.1, "answer": [0, 4]}, |
||
| 27 | ], |
||
| 28 | } |
||
| 29 | |||
| 30 | def test_Basics(self): |
||
| 31 | for i in self.TESTS['Basics']: |
||
| 32 | assert checkio(i['input']) == i['answer'] |
||
| 33 | |||
| 34 | def test_Extra(self): |
||
| 35 | for i in self.TESTS['Extra']: |
||
| 36 | assert checkio(i['input']) == i['answer'] |
||
| 37 | |||
| 38 | |||
| 39 | if __name__ == "__main__": # pragma: no cover |
||
| 40 | unittest.main() |
||
| 41 |