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

coalib.tests.coalaFormatTest.tearDown()   A

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 2
rs 10
1
import os
2
import re
3
import sys
4
import unittest
5
6
from coalib import coala_format
7
from coalib.tests.TestUtilities import execute_coala
8
from coalib.misc.ContextManagers import prepare_file
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 prepare_file(["#fixme"], None) as (lines, filename):
21
            bear = "LineCountBear"
22
            retval, output = execute_coala(
23
                             coala_format.main,
24
                            "coala-format", "-c", os.devnull,
25
                            "--settings", "files=" + re.escape(filename),
26
                            "bears=" + bear)
27
            self.assertRegex(output,
28
                             r'msg:This file has [0-9]+ lines.',
29
                             "coala-format output for line count should"
30
                             " not be empty")
31
            self.assertEqual(retval,
32
                             1,
33
                             "coala-format must return exitcode 1 when it "
34
                             "yields results")
35