1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/master/COPYING
"""Tests for the misc checker."""
import unittest
from pylint.checkers import misc
from pylint.testutils import (
CheckerTestCase, Message,
set_config, create_file_backed_module,
)
class FixmeTest(CheckerTestCase):
CHECKER_CLASS = misc.EncodingChecker
def test_fixme_with_message(self):
with create_file_backed_module(
"""a = 1
# FIXME message
""") as module:
with self.assertAddsMessages(
Message(msg_id='fixme', line=2, args=u'FIXME message')):
self.checker.process_module(module)
def test_todo_without_message(self):
with create_file_backed_module(
"""a = 1
# TODO
""") as module:
with self.assertAddsMessages(
Message(msg_id='fixme', line=2, args=u'TODO')):
self.checker.process_module(module)
def test_xxx_without_space(self):
with create_file_backed_module(
"""a = 1
#XXX
""") as module:
with self.assertAddsMessages(
Message(msg_id='fixme', line=2, args=u'XXX')):
self.checker.process_module(module)
def test_xxx_middle(self):
with create_file_backed_module(
"""a = 1
# midle XXX
""") as module:
with self.assertNoMessages():
self.checker.process_module(module)
def test_without_space_fixme(self):
with create_file_backed_module(
"""a = 1
#FIXME
""") as module:
with self.assertAddsMessages(
Message(msg_id='fixme', line=2, args=u'FIXME')):
self.checker.process_module(module)
@set_config(notes=[])
def test_absent_codetag(self):
with create_file_backed_module(
"""a = 1
# FIXME
# TODO
# XXX
""") as module:
with self.assertNoMessages():
self.checker.process_module(module)
@set_config(notes=['CODETAG'])
def test_other_present_codetag(self):
with create_file_backed_module(
"""a = 1
# CODETAG
# FIXME
""") as module:
with self.assertAddsMessages(
Message(msg_id='fixme', line=2, args=u'CODETAG')):
self.checker.process_module(module)
if __name__ == '__main__':
unittest.main()
|