Completed
Pull Request — master (#1109)
by Abdeali
01:48
created

bears.tests.css.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 subprocess
3
import sys
4
from queue import Queue
5
6
sys.path.insert(0, ".")
7
import unittest
8
from bears.tests.LocalBearTestHelper import LocalBearTestHelper
9
from bears.css.CSSLintBear import CSSLintBear
10
from coalib.settings.Section import Section
11
12
13
class CSSLintBearTest(LocalBearTestHelper):
14
    def setUp(self):
15
        self.section = Section("test section")
16
        self.uut = CSSLintBear(self.section, Queue())
17
        self.test_file1 = os.path.join(os.path.dirname(__file__),
18
                                       "test_files",
19
                                       "csslint_test1.css")
20
        self.test_file2 = os.path.join(os.path.dirname(__file__),
21
                                       "test_files",
22
                                       "csslint_test2.css")
23
24
    def test_run(self):
25
        # Test a file without any issues
26
        self.assertLinesValid(self.uut, [], self.test_file1)
27
28
        # Test a file with errors and warnings
29
        self.assertLinesInvalid(self.uut, [], self.test_file2)
30
31
32
def skip_test():
33
    try:
34
        subprocess.Popen(['csslint', '--version'],
35
                         stdout=subprocess.PIPE,
36
                         stderr=subprocess.PIPE)
37
        return False
38
    except OSError:
39
        return "csslint is not installed."
40
41
42
if __name__ == '__main__':
43
    unittest.main(verbosity=2)
44