coalaFormatTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A tearDown() 0 2 1
A test_line_count() 0 12 2
A setUp() 0 2 1
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):
12
13
    def setUp(self):
14
        self.old_argv = sys.argv
15
16
    def tearDown(self):
17
        sys.argv = self.old_argv
18
19
    def test_line_count(self):
20
        with bear_test_module(), \
21
                prepare_file(["#fixme"], None) as (lines, filename):
22
            retval, output = execute_coala(coala_format.main, "coala-format",
23
                                           "-c", os.devnull,
24
                                           "-f", re.escape(filename),
25
                                           "-b", "LineCountTestBear")
26
            self.assertRegex(output, r'message:This file has [0-9]+ lines.',
27
                             "coala-format output for line count should "
28
                             "not be empty")
29
            self.assertEqual(retval, 1,
30
                             "coala-format must return exitcode 1 when it "
31
                             "yields results")
32