Failed Conditions
Pull Request — master (#1182)
by Lasse
01:44
created

bears.tests.python.skip_test()   A

Complexity

Conditions 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 2
dl 0
loc 8
rs 9.4286
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.python.PyLintBear import PyLintBear
12
from coalib.settings.Section import Section
13
14
15
@skipIf(which('pylint') is None, 'PyLint is not installed')
16
class PyLintBearTest(LocalBearTestHelper):
17
    def setUp(self):
18
        self.section = Section("test section")
19
        self.uut = PyLintBear(self.section, Queue())
20
        self.test_file = os.path.join(os.path.dirname(__file__),
21
                                      "test_files",
22
                                      "pylint_test.py")
23
24
    def test_run(self):
25
        self.section.append(Setting("pylint_disable", ""))
26
        self.assertLinesInvalid(
27
            self.uut,
28
            [],  # Doesn't matter, pylint will parse the file
29
            self.test_file)
30
31
        # This is a special case because there's only one result yielded.
32
        # This was a bug once where the last result got ignored.
33
        self.section.append(Setting("pylint_disable", "E0211,W0611,C0111"))
34
        self.assertLinesInvalid(
35
            self.uut,
36
            [],
37
            self.test_file)
38
39
        self.section.append(
40
            Setting("pylint_disable", "E0211,W0611,C0111,W0311"))
41
        self.assertLinesValid(
42
            self.uut,
43
            [],
44
            self.test_file)
45
46
        self.section.append(Setting("pylint_disable", "all"))
47
        self.assertLinesValid(
48
            self.uut,
49
            [],
50
            self.test_file)
51
52
        self.section.append(Setting("pylint_enable", "C0111"))
53
        self.assertLinesInvalid(
54
            self.uut,
55
            [],
56
            self.test_file)
57
58
        self.section.append(Setting("pylint_cli_options", "--disable=all"))
59
        self.assertLinesValid(
60
            self.uut,
61
            [],
62
            self.test_file)
63
64
65
if __name__ == '__main__':
66
    unittest.main(verbosity=2)
67