Completed
Pull Request — master (#2609)
by Udayan
02:12
created

FileWiseBearTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 21
Duplicated Lines 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 21
loc 21
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 3 3 1
A test_bear_executions() 6 6 2
A test_api() 5 5 1
A test_kind() 2 2 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 unittest
2
3
from coalib.bears.FileWiseBear import BEAR_KIND, FileWiseBear
4
from coalib.settings.Section import Section
5
6
7
class DummyFileProxy:
8
9
    def __init__(self, lines):
10
        self.lines = lines
11
12
13 View Code Duplication
class FileWiseBearTest(unittest.TestCase):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
14
15
    def setUp(self):
16
        file_set = {DummyFileProxy([]), DummyFileProxy(["a\n"])}
17
        self.test_object = FileWiseBear(file_set, Section("Name"), None)
18
19
    def test_api(self):
20
        test_object = FileWiseBear(None, Section("name"), None)
21
        self.assertRaises(NotImplementedError,
22
                          test_object.analyze,
23
                          "file")
24
25
    def test_kind(self):
26
        self.assertEqual(FileWiseBear.kind(), BEAR_KIND.FILEWISE)
27
28
    def test_bear_executions(self):
29
        for task in self.test_object.generate_tasks():
30
            self.assertRaises(NotImplementedError,
31
                              self.test_object.execute_task,
32
                              task[0],
33
                              task[1])
34