Failed Conditions
Pull Request — master (#1093)
by Lasse
01:45
created

setUp()   A

Complexity

Conditions 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 4
rs 10
1
from queue import Queue
2
import sys
3
import unittest
4
import subprocess
5
6
7
sys.path.insert(0, ".")
8
from bears.tests.LocalBearTestHelper import LocalBearTestHelper
9
from bears.linters.IndentBear import IndentBear
10
from coalib.settings.Section import Section
11
12
13
class CorrectionBasedBearTest(LocalBearTestHelper):
14
    """
15
    This test only covers corner cases. The basic functionality is tested in
16
    a more intuitive way in the IndentBearTest.
17
    """
18
19
    def setUp(self):
20
        self.section = Section('')
21
        self.queue = Queue()
22
        self.uut = IndentBear(self.section, self.queue)
23
24
    def test_errors(self):
25
        old_binary, self.uut.BINARY = self.uut.BINARY, "invalid_stuff_here"
26
27
        self.uut.execute(filename='', file=[])
28
        self.queue.get()
29
        self.assertRegex(str(self.queue.get()), r'\[WARNING\] .*')
30
31
        self.uut.BINARY = old_binary
32
33
34
def skip_test():
35
    try:
36
        subprocess.Popen([IndentBear.BINARY, '--version'],
37
                         stdout=subprocess.PIPE,
38
                         stderr=subprocess.PIPE)
39
        return False
40
    except OSError:
41
        return "indent is not installed."
42
43
44
if __name__ == '__main__':
45
    unittest.main(verbosity=2)
46