Passed
Push — master ( 2a32d2...dc515b )
by Ken M.
01:12
created

test_the_longest_palindromic   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 76.19 %

Importance

Changes 0
Metric Value
eloc 28
dl 32
loc 42
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 the_longest_palindromic import longest_palindromic
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": "abc", "answer": "a"},
10
            {"input": "abacada", "answer": "aba"},
11
            {"input": "artrartrt", "answer": "rtrartr"},
12
            {"input": "aaaaa", "answer": "aaaaa"},
13
        ],
14
        "Extra": [
15
            {"input": "so sad das-li", "answer": "sad das"},
16
            {"input": " a b c", "answer": " a "},
17
            {"input": "1", "answer": "1"},
18
            {
19
                "input": "123abcba",
20
                "answer": "abcba",
21
                "explanation": "At the end of text",
22
            },
23
            {
24
                "input": "abcba123abcdcba",
25
                "answer": "abcdcba",
26
                "explanation": "Two palindromes in text",
27
            },
28
        ],
29
    }
30
31
    def test_Basics(self):
32
        for i in self.TESTS['Basics']:
33
            assert longest_palindromic(i['input']) == i['answer'], i['input']
34
35
    def test_Extra(self):
36
        for i in self.TESTS['Extra']:
37
            assert longest_palindromic(i['input']) == i['answer'], i['input']
38
39
40
if __name__ == "__main__":  # pragma: no cover
41
    unittest.main()
42