Failed Conditions
Pull Request — master (#1109)
by Abdeali
01:46
created

bears.tests.linters.DockerfileLintBearTest   A

Complexity

Total Complexity 2

Size/Duplication

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_run() 0 3 1
A setUp() 0 9 1
1
import os
2
import subprocess
3
import sys
4
from queue import Queue
5
6
sys.path.insert(0, ".")
7
import unittest
8
from coalib.settings.Setting import Setting
0 ignored issues
show
Unused Code introduced by
Unused Setting imported from coalib.settings.Setting
Loading history...
9
from bears.tests.LocalBearTestHelper import LocalBearTestHelper
10
from bears.linters.DockerfileLintBear import DockerfileLintBear
11
from coalib.settings.Section import Section
12
13
14
class DockerfileLintBearTest(LocalBearTestHelper):
15
    def setUp(self):
16
        self.section = Section("test section")
17
        self.uut = DockerfileLintBear(self.section, Queue())
18
        self.test_file1 = os.path.join(os.path.dirname(__file__),
19
                                       "test_files",
20
                                       "dockerfilelint_test1")
21
        self.test_file2 = os.path.join(os.path.dirname(__file__),
22
                                       "test_files",
23
                                       "dockerfilelint_test2")
24
25
    def test_run(self):
26
        self.assertLinesValid(self.uut, [], self.test_file1)
27
        self.assertLinesInvalid(self.uut, [], self.test_file2)
28
29
30
def skip_test():
31
    try:
32
        subprocess.Popen(['dockerfile_lint', '--version'],
33
                         stdout=subprocess.PIPE,
34
                         stderr=subprocess.PIPE)
35
        return False
36
    except OSError:
37
        return "dockerfile-lint is not installed."
38
39
40
if __name__ == '__main__':
41
    unittest.main(verbosity=2)
42