Completed
Pull Request — master (#1116)
by Lasse
01:40
created

coalib.tests.bearlib.abstractions.CorrectionBasedBearTest   A

Complexity

Total Complexity 2

Size/Duplication

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_errors() 0 8 1
A setUp() 0 4 1
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
11
12
class CorrectionBasedBearTest(LocalBearTestHelper):
13
    """
14
    This test only covers corner cases. The basic functionality is tested in
15
    a more intuitive way in the IndentBearTest.
16
    """
17
18
    def setUp(self):
19
        self.section = Section('')
20
        self.queue = Queue()
21
        self.uut = IndentBear(self.section, self.queue)
22
23
    def test_errors(self):
24
        old_binary, self.uut.BINARY = self.uut.BINARY, "invalid_stuff_here"
25
26
        self.uut.execute(filename='', file=[])
27
        self.queue.get()
28
        self.assertRegex(str(self.queue.get()), r'\[WARNING\] .*')
29
30
        self.uut.BINARY = old_binary
31
32
33
def skip_test():
34
    try:
35
        subprocess.Popen([IndentBear.BINARY, '--version'],
36
                         stdout=subprocess.PIPE,
37
                         stderr=subprocess.PIPE)
38
        return False
39
    except OSError:
40
        return "indent is not installed."
41
42
43
if __name__ == '__main__':
44
    unittest.main(verbosity=2)
45