Completed
Pull Request — master (#1263)
by Lasse
01:46
created

test_ignore_regex()   A

Complexity

Conditions 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 5
rs 9.4285
1
from queue import Queue
2
import sys
3
4
sys.path.insert(0, ".")
5
import unittest
6
from coalib.settings.Setting import Setting
7
from bears.tests.LocalBearTestHelper import LocalBearTestHelper
8
from coalib.settings.Section import Section
9
from bears.general.LineLengthBear import LineLengthBear
10
11
12
class LineLengthBearTest(LocalBearTestHelper):
13
14
    def setUp(self):
15
        self.section = Section("test section")
16
        self.section.append(Setting("max_line_length", "4"))
17
        self.uut = LineLengthBear(self.section, Queue())
18
19
    def test_run(self):
20
        self.assertLinesValid(self.uut, [
21
            "test\n",
22
            "too\n",
23
            "er\n",
24
            "e\n",
25
            "\n"
26
        ])
27
        self.assertLineInvalid(self.uut, "testa\n")
28
        self.assertLineInvalid(self.uut, "test line\n")
29
30
    def test_ignore_regex(self):
31
        self.section['ignore_length_regex'] = 'http://'
32
33
        self.assertLineInvalid(self.uut, 'asdasd')
34
        self.assertLineValid(self.uut, 'http://a.domain.de')
35
36
37
if __name__ == '__main__':
38
    unittest.main(verbosity=2)
39