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

test_run()   A

Complexity

Conditions 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 6
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.c_languages.CSharpLintBear import CSharpLintBear
10
from coalib.settings.Section import Section
11
12
13
class CSharpLintBearTest(LocalBearTestHelper):
14
    def setUp(self):
15
        self.section = Section("test section")
16
        self.uut = CSharpLintBear(self.section, Queue())
17
        self.test_file1 = os.path.join(os.path.dirname(__file__),
18
                                       "test_files",
19
                                       "csharplint_test1.cs")
20
        self.test_file2 = os.path.join(os.path.dirname(__file__),
21
                                       "test_files",
22
                                       "csharplint_test2.cs")
23
24
    def test_run(self):
25
        # Test a file with no issues
26
        self.assertLinesValid(self.uut, [], self.test_file1)
27
28
        # Test a file with issues
29
        self.assertLinesInvalid(self.uut, [], self.test_file2)
30
31
32
def skip_test():
33
    try:
34
        subprocess.Popen(['mcs', '--version'],
35
                         stdout=subprocess.PIPE,
36
                         stderr=subprocess.PIPE)
37
        return False
38
    except OSError:
39
        return "mono's mcs is not installed."
40
41
42
if __name__ == '__main__':
43
    unittest.main(verbosity=2)
44