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

setUp()   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 3
rs 10
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
18
    @staticmethod
19
    def get_test_filename(basename):
20
        return os.path.join(os.path.dirname(__file__),
21
                            "test_files",
22
                            basename + ".coffee")
23
24
    def test_good(self):
25
        good_file = self.get_test_filename("good")
26
        self.assertLinesValid(self.uut, [], good_file)
27
28
    def test_warn(self):
29
        warn_file = self.get_test_filename("warning")
30
        self.assertLinesInvalid(self.uut, [], warn_file)
31
32
    def test_err(self):
33
        err_file = self.get_test_filename("error")
34
        self.assertLinesInvalid(self.uut, [], err_file)
35
36
    def test_invalid(self):
37
        # CoffeeLint will generate an invalid CSV on this one!
38
        invalid_file = self.get_test_filename("invalid")
39
        self.assertLinesInvalid(self.uut, [], invalid_file)
40
41
42
def skip_test():
43
    try:
44
        subprocess.Popen(['coffeelint', '--version'],
45
                         stdout=subprocess.PIPE,
46
                         stderr=subprocess.PIPE)
47
        return False
48
    except OSError:
49
        return "coffeelint is not installed."
50
51
52
if __name__ == '__main__':
53
    unittest.main(verbosity=2)
54