Completed
Pull Request — master (#1291)
by Sudheesh
01:32
created

bears.tests.go.GoLintBearTest.setUp()   A

Complexity

Conditions 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 9
rs 9.6666
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.go.GoLintBear import GoLintBear
12
from coalib.settings.Section import Section
13
14
15
@skipIf(which('golint') is None, 'golint is not installed')
16
class GoLintBearTest(LocalBearTestHelper):
17
18
    def setUp(self):
19
        self.section = Section("Test Section")
20
        self.uut = GoLintBear(self.section, Queue())
21
        self.good_file = os.path.join(os.path.dirname(__file__),
22
                                      "test_files",
23
                                      "golint_good.go")
24
        self.bad_file = os.path.join(os.path.dirname(__file__),
25
                                     "test_files",
26
                                     "golint_bad.go")
27
28
    def test_run(self):
29
        self.assertLinesValid(self.uut, [], self.good_file)
30
        self.assertLinesInvalid(self.uut, [], self.bad_file)
31
        self.section.append(Setting("golint_cli_options",
32
                                    "-min_confidence=0.8"))
33
        self.assertLinesInvalid(self.uut, [], self.bad_file)
34
35
if __name__ == '__main__':
36
    unittest.main(verbosity=2)
37