Completed
Pull Request — master (#1073)
by Lasse
01:56
created

test_valid()   A

Complexity

Conditions 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 11
rs 9.4286
1
import sys
2
import unittest
3
from queue import Queue
4
5
sys.path.insert(0, ".")
6
from bears.tests.LocalBearTestHelper import LocalBearTestHelper
7
from bears.Python.PyCommentedCodeBear import PyCommentedCodeBear
8
from coalib.settings.Section import Section
9
10
11
class PyCommentedCodeBearTest(LocalBearTestHelper):
12
    def setUp(self):
13
        self.uut = PyCommentedCodeBear(Section('name'), Queue())
14
15
    def test_valid(self):
16
        self.assertLinesValid(self.uut, ["import sys"])
17
        self.assertLinesValid(self.uut, ["a = 1 + 1"])
18
        self.assertLinesValid(self.uut, ["# hey man!"])
19
        self.assertLinesValid(self.uut, ['"""',
20
                                         'Hey, this is a code sample:',
21
                                         '>>> import os',
22
                                         '',
23
                                         'And when you use it you can simply '
24
                                         'do: `import os`.',
25
                                         '"""'])
26
27
    def test_invalid(self):
28
        self.assertLinesInvalid(self.uut, ["# import os"])
29
        self.assertLinesInvalid(self.uut, ["# print('comment')"])
30
31
32
if __name__ == '__main__':
33
    unittest.main(verbosity=2)
34