Failed Conditions
Pull Request — master (#1297)
by Sudheesh
01:51
created

bears.tests.perl.PerlCriticBearTest.setUp()   A

Complexity

Conditions 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 12
rs 9.4285
1
import os
2
import sys
3
from queue import Queue
4
from shutil import which
5
from unittest.case import skipIf
6
7
sys.path.insert(0, ".")
8
import unittest
9
from coalib.settings.Setting import Setting
10
from bears.tests.LocalBearTestHelper import LocalBearTestHelper
11
from bears.perl.PerlCriticBear import PerlCriticBear
12
from coalib.settings.Section import Section
13
14
15
@skipIf(which('perlcritic') is None, 'perlcritic is not installed')
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
class PerlCriticBearTest(LocalBearTestHelper):
17
18
    def setUp(self):
19
        self.section = Section("Test Section")
20
        self.uut = PerlCriticBear(self.section, Queue())
21
        self.good_file = os.path.join(os.path.dirname(__file__),
22
                                      "test_files",
23
                                      "perlcritic_good.pl")
24
        self.bad_file = os.path.join(os.path.dirname(__file__),
25
                                     "test_files",
26
                                     "perlcritic_bad.pl")
27
        self.conf_file = os.path.join(os.path.dirname(__file__),
28
                                      "test_files",
29
                                      "perlcritic_config.pl")
30
31
    def test_run(self):
32
        self.assertLinesValid(self.uut, [], self.good_file)
33
        self.assertLinesInvalid(self.uut, [], self.bad_file)
34
        self.section.append(Setting("perlcritic_config", self.conf_file))
35
        self.assertLinesValid(self.uut, [], self.bad_file)
36
37
if __name__ == '__main__':
38
    unittest.main(verbosity=2)
39