Completed
Pull Request — master (#1146)
by Lasse
01:44
created

bears.tests.c_languages.CPPLintBearTest.test_run()   A

Complexity

Conditions 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 7
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.CPPLintBear import CPPLintBear
10
from coalib.settings.Section import Section
11
from coalib.settings.Setting import Setting
12
13
14
class CPPLintBearTest(LocalBearTestHelper):
15
    def setUp(self):
16
        self.section = Section("test section")
17
        self.uut = CPPLintBear(self.section, Queue())
18
        self.test_file = os.path.join(os.path.dirname(__file__),
19
                                      "test_files",
20
                                      "cpplint_bear_test.cpp")
21
22
    def test_run(self):
23
        # Should yield missing copyright line
24
        self.assertLinesInvalid(self.uut, [], self.test_file)
25
26
        # Let's ignore legal issues
27
        self.section.append(Setting("cpplint_ignore", "legal"))
28
        self.assertLinesValid(self.uut, [], self.test_file)
29
30
31
def skip_test():
32
    try:
33
        subprocess.Popen(['cpplint', '--help'],
34
                         stdout=subprocess.PIPE,
35
                         stderr=subprocess.PIPE)
36
        return False
37
    except OSError:
38
        return "cpplint is not installed."
39
40
41
if __name__ == '__main__':
42
    unittest.main(verbosity=2)
43