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

bears.tests.c_languages.CPPLintBearTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %
Metric Value
dl 0
loc 15
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_run() 0 7 1
A setUp() 0 6 1
1
import os
2
import subprocess
3
import sys
4
from queue import Queue
5
6
7
sys.path.insert(0, ".")
8
import unittest
9
from bears.tests.LocalBearTestHelper import LocalBearTestHelper
10
from bears.c_languages.CPPLintBear import CPPLintBear
11
from coalib.settings.Section import Section
12
from coalib.settings.Setting import Setting
13
14
15
class CPPLintBearTest(LocalBearTestHelper):
16
    def setUp(self):
17
        self.section = Section("test section")
18
        self.uut = CPPLintBear(self.section, Queue())
19
        self.test_file = os.path.join(os.path.dirname(__file__),
20
                                      "test_files",
21
                                      "cpplint_bear_test.cpp")
22
23
    def test_run(self):
24
        # Should yield missing copyright line
25
        self.assertLinesInvalid(self.uut, [], self.test_file)
26
27
        # Let's ignore legal issues
28
        self.section.append(Setting("cpplint_ignore", "legal"))
29
        self.assertLinesValid(self.uut, [], self.test_file)
30
31
32
def skip_test():
33
    try:
34
        subprocess.Popen(['cpplint', '--help'],
35
                         stdout=subprocess.PIPE,
36
                         stderr=subprocess.PIPE)
37
        return False
38
    except OSError:
39
        return "cpplint is not installed."
40
41
42
if __name__ == '__main__':
43
    unittest.main(verbosity=2)
44