Failed Conditions
Pull Request — master (#1438)
by Sudheesh
01:52 queued 17s
created

bears.tests.js.ESLintBearTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %
Metric Value
dl 0
loc 24
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 12 1
A test_run() 0 8 1
1
import os
2
from queue import Queue
3
from shutil import which
4
from unittest.case import skipIf
5
6
from coalib.settings.Setting import Setting
7
from bears.tests.LocalBearTestHelper import LocalBearTestHelper
8
from bears.js.ESLintBear import ESLintBear
9
from coalib.settings.Section import Section
10
11
12
@skipIf(which('eslint') is None, 'ESLint 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...
13
class ESLintBearTest(LocalBearTestHelper):
14
15
    def setUp(self):
16
        self.section = Section("test section")
17
        self.uut = ESLintBear(self.section, Queue())
18
        self.test_good = os.path.join(os.path.dirname(__file__),
19
                                      "test_files",
20
                                      "eslint_good.js")
21
        self.test_bad = os.path.join(os.path.dirname(__file__),
22
                                     "test_files",
23
                                     "eslint_bad.js")
24
        self.test_config = os.path.join(os.path.dirname(__file__),
25
                                        "test_files",
26
                                        "eslint_config.js")
27
28
    def test_run(self):
29
        # Test a file with errors and warnings
30
        self.assertLinesInvalid(self.uut, [], self.test_bad)
31
        # Test a file without errors and warnings
32
        self.assertLinesValid(self.uut, [], self.test_good)
33
        # Append the config to the file with errors and test again
34
        self.section.append(Setting("eslint_config", self.test_config))
35
        self.assertLinesValid(self.uut, [], self.test_bad)
36