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

bears.tests.js.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.js.JSHintBear import JSHintBear
12
from coalib.settings.Section import Section
13
14
15
@skipIf(which('jshint') is None, 'JSHint is not installed')
16
class JSHintBearTest(LocalBearTestHelper):
17
    def setUp(self):
18
        self.section = Section("test section")
19
        self.uut = JSHintBear(self.section, Queue())
20
        self.test_file1 = os.path.join(os.path.dirname(__file__),
21
                                       "test_files",
22
                                       "jshint_test1.js")
23
        self.test_file2 = os.path.join(os.path.dirname(__file__),
24
                                       "test_files",
25
                                       "jshint_test2.js")
26
        self.conf_file = os.path.join(os.path.dirname(__file__),
27
                                      "test_files",
28
                                      "jshint_config.js")
29
30
    def test_run(self):
31
        # Test a file with errors and warnings
32
        self.assertLinesInvalid(
33
            self.uut,
34
            [],
35
            self.test_file2)
36
37
        # Test a file with a warning which can be changed using a config
38
        self.assertLinesInvalid(
39
            self.uut,
40
            [],
41
            self.test_file1)
42
43
        # Test if warning disappears
44
        self.section.append(Setting("jshint_config", self.conf_file))
45
        self.assertLinesValid(
46
            self.uut,
47
            [],
48
            self.test_file1)
49
50
51
if __name__ == '__main__':
52
    unittest.main(verbosity=2)
53