Completed
Pull Request — master (#1106)
by Lasse
02:11
created

test_invalid()   A

Complexity

Conditions 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 4
rs 10
1
import subprocess
2
import sys
3
import unittest
4
from queue import Queue
5
6
sys.path.insert(0, ".")
7
from bears.tests.LocalBearTestHelper import LocalBearTestHelper
8
from bears.c_languages.IndentBear import IndentBear
9
from coalib.settings.Section import Section
10
from coalib.settings.Setting import Setting
11
12
13
class IndentBearTest(LocalBearTestHelper):
14
    def setUp(self):
15
        self.section = Section('name')
16
        self.uut = IndentBear(self.section, Queue())
17
18
    def test_valid(self):
19
        self.assertLinesValid(self.uut, ["int main()\n",
20
                                         "{\n",
21
                                         "    return 0;\n",
22
                                         "}\n"])
23
24
    def test_valid_gnu(self):
25
        self.section.append(Setting("indent_cli_options", "-gnu"))
26
        self.assertLinesValid(self.uut, ["int\n",
27
                                         "main ()\n",
28
                                         "{\n",
29
                                         "  return 0;\n",
30
                                         "}\n"])
31
32
    def test_invalid(self):
33
        self.assertLinesInvalid(self.uut, ["int main() {\n",
34
                                           "  return 0;\n",
35
                                           "}\n"])
36
37
38
def skip_test():
39
    try:
40
        subprocess.Popen([IndentBear.BINARY, '--version'],
41
                         stdout=subprocess.PIPE,
42
                         stderr=subprocess.PIPE)
43
        return False
44
    except OSError:
45
        return "indent is not installed."
46
47
48
if __name__ == '__main__':
49
    unittest.main(verbosity=2)
50