Completed
Pull Request — master (#1152)
by Lasse
01:38
created

bears.tests.coffee_script.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
import unittest
5
from queue import Queue
6
7
sys.path.insert(0, ".")
8
from bears.tests.LocalBearTestHelper import LocalBearTestHelper
9
from bears.coffee_script.CoffeeLintBear import CoffeeLintBear
10
from coalib.settings.Section import Section
11
12
13
class CoffeeLintBearTest(LocalBearTestHelper):
14
    def setUp(self):
15
        self.section = Section("test section")
16
        self.uut = CoffeeLintBear(self.section, Queue())
17
        self.warn_file = os.path.join(os.path.dirname(__file__),
18
                                      "test_files",
19
                                      "warning.coffee")
20
        self.error_file = os.path.join(os.path.dirname(__file__),
21
                                       "test_files",
22
                                       "error.coffee")
23
        self.invalid_file = os.path.join(os.path.dirname(__file__),
24
                                         "test_files",
25
                                         "invalid.coffee")
26
27
    def test_good(self):
28
        good_file = os.path.join(os.path.dirname(__file__),
29
                                 "test_files",
30
                                 "good.coffee")
31
        self.assertLinesValid(self.uut, [], good_file)
32
33
    def test_warn(self):
34
        warn_file = os.path.join(os.path.dirname(__file__),
35
                                 "test_files",
36
                                 "warning.coffee")
37
        self.assertLinesInvalid(self.uut, [], warn_file)
38
39
    def test_err(self):
40
        err_file = os.path.join(os.path.dirname(__file__),
41
                                "test_files",
42
                                "error.coffee")
43
        self.assertLinesInvalid(self.uut, [], err_file)
44
45
    def test_invalid(self):
46
        # CoffeeLint will generate an invalid CSV on this one!
47
        invalid_file = os.path.join(os.path.dirname(__file__),
48
                                    "test_files",
49
                                    "invalid.coffee")
50
        self.assertLinesInvalid(self.uut, [], invalid_file)
51
52
53
def skip_test():
54
    try:
55
        subprocess.Popen(['coffeelint', '--version'],
56
                         stdout=subprocess.PIPE,
57
                         stderr=subprocess.PIPE)
58
        return False
59
    except OSError:
60
        return "coffeelint is not installed."
61
62
63
if __name__ == '__main__':
64
    unittest.main(verbosity=2)
65