Completed
Pull Request — master (#1504)
by Abdeali
01:41
created

coalib.tests.coalaFormatTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %
Metric Value
dl 0
loc 23
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A tearDown() 0 2 1
A setUp() 0 2 1
A test_line_count() 0 15 2
1
import sys
2
import os
3
import unittest
4
5
from coalib import coala_format
6
from coalib.tests.TestUtilities import execute_coala
7
from coalib.misc.ContextManagers import prepare_file
8
9
10
class coalaFormatTest(unittest.TestCase):
11
12
    def setUp(self):
13
        self.old_argv = sys.argv
14
15
    def tearDown(self):
16
        sys.argv = self.old_argv
17
18
    def test_line_count(self):
19
        with prepare_file(["#fixme"], None) as (lines, filename):
20
            bear = "LineCountBear"
21
            retval, output = execute_coala(
22
                             coala_format.main,
23
                            "coala-format", "-c", os.devnull,
24
                            "--settings", "files=" + filename,
25
                            "bears=" + bear)
26
            self.assertRegex(output,
27
                             r'msg:This file has [0-9]+ lines.',
28
                             "coala-format output for line count should"
29
                             " not be empty")
30
            self.assertEqual(retval,
31
                             1,
32
                             "coala-format must return exitcode 1 when it "
33
                             "yields results")
34