Failed Conditions
Pull Request — master (#2076)
by Abdeali
02:11
created

tests/coalaFormatTest.py (9 issues)

1
import os
2
import re
3
import sys
4
import unittest
5
6
from coalib import coala_format
7
from coalib.misc.ContextManagers import prepare_file
8
from tests.TestUtilities import bear_test_module, execute_coala
9
10
11
class coalaFormatTest(unittest.TestCase):
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable unittest does not seem to be defined.
Loading history...
12
13
    def setUp(self):
14
        self.old_argv = sys.argv
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable sys does not seem to be defined.
Loading history...
15
16
    def tearDown(self):
17
        sys.argv = self.old_argv
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable self does not seem to be defined.
Loading history...
18
19
    def test_line_count(self):
20
        with bear_test_module(), \
21
                prepare_file(["#fixme"], None) as (lines, filename):
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable filename does not seem to be defined.
Loading history...
Comprehensibility Best Practice introduced by
The variable lines does not seem to be defined.
Loading history...
22
            retval, output = execute_coala(coala_format.main, "coala-format",
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable coala_format does not seem to be defined.
Loading history...
23
                                           "-c", os.devnull,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable os does not seem to be defined.
Loading history...
24
                                           "-f", re.escape(filename),
25
                                           "-b", "LineCountTestBear")
26
            self.assertRegex(output, r'message:This file has [0-9]+ lines.',
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable output does not seem to be defined.
Loading history...
27
                             "coala-format output for line count should "
28
                             "not be empty")
29
            self.assertEqual(retval, 1,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable retval does not seem to be defined.
Loading history...
30
                             "coala-format must return exitcode 1 when it "
31
                             "yields results")
32