@@ -116,3 +116,128 @@ def test_dont_trigger_on_todoist(self) -> None:
116116 """
117117 with self .assertNoMessages ():
118118 self .checker .process_tokens (_tokenize_str (code ))
119+
120+ @set_config (check_fixme_in_docstring = True )
121+ def test_docstring_with_message (self ) -> None :
122+ code = """
123+ \" \" \" FIXME message\" \" \"
124+ """
125+ with self .assertAddsMessages (
126+ MessageTest (msg_id = "fixme" , line = 2 , args = "FIXME message" , col_offset = 9 )
127+
128+ ):
129+ self .checker .process_tokens (_tokenize_str (code ))
130+
131+ @set_config (check_fixme_in_docstring = True )
132+ def test_docstring_with_nl_message (self ) -> None :
133+ code = """
134+ \" \" \"
135+ FIXME message
136+ \" \" \"
137+ """
138+ with self .assertAddsMessages (
139+ MessageTest (msg_id = "fixme" , line = 3 , args = "FIXME message" , col_offset = 9 )
140+ ):
141+ self .checker .process_tokens (_tokenize_str (code ))
142+
143+ @set_config (check_fixme_in_docstring = True )
144+ def test_docstring_with_nl_message_multi (self ) -> None :
145+ code = """
146+ \" \" \"
147+ FIXME this
148+ TODO: that
149+ \" \" \"
150+ """
151+ with self .assertAddsMessages (
152+ MessageTest (msg_id = "fixme" , line = 3 , args = "FIXME this" , col_offset = 9 ),
153+ MessageTest (msg_id = "fixme" , line = 4 , args = "TODO: that" , col_offset = 9 )
154+ ):
155+ self .checker .process_tokens (_tokenize_str (code ))
156+
157+ @set_config (check_fixme_in_docstring = True )
158+ def test_docstring_with_comment (self ) -> None :
159+ code = """
160+ # XXX message1
161+ \" \" \"
162+ FIXME message2
163+ TODO message3
164+ \" \" \"
165+ """
166+ with self .assertAddsMessages (
167+ MessageTest (msg_id = "fixme" , line = 2 , args = "XXX message1" , col_offset = 9 ),
168+ MessageTest (msg_id = "fixme" , line = 4 , args = "FIXME message2" , col_offset = 9 ),
169+ MessageTest (msg_id = "fixme" , line = 5 , args = "TODO message3" , col_offset = 9 )
170+ ):
171+ self .checker .process_tokens (_tokenize_str (code ))
172+
173+ @set_config (check_fixme_in_docstring = True )
174+ def test_docstring_with_comment_prefix (self ) -> None :
175+ code = """
176+ # \" \" \" XXX should not trigger
177+ \" \" \" # XXX should not trigger \" \" \"
178+ """
179+ with self .assertNoMessages ():
180+ self .checker .process_tokens (_tokenize_str (code ))
181+
182+ @set_config (check_fixme_in_docstring = True )
183+ def test_docstring_todo_middle_nl (self ) -> None :
184+ code = """
185+ \" \" \"
186+ something FIXME message
187+ \" \" \"
188+ """
189+ with self .assertNoMessages ():
190+ self .checker .process_tokens (_tokenize_str (code ))
191+
192+ @set_config (check_fixme_in_docstring = True )
193+ def test_docstring_todo_middle (self ) -> None :
194+ code = """
195+ \" \" \" something FIXME message
196+ \" \" \"
197+ """
198+ with self .assertNoMessages ():
199+ self .checker .process_tokens (_tokenize_str (code ))
200+
201+ @set_config (check_fixme_in_docstring = True )
202+ def test_docstring_todo_mult (self ) -> None :
203+ code = """
204+ \" \" \"
205+ FIXME this TODO that
206+ \" \" \"
207+ """
208+ with self .assertAddsMessages (
209+ MessageTest (msg_id = "fixme" , line = 3 , args = "FIXME this TODO that" , col_offset = 9 ),
210+ ):
211+ self .checker .process_tokens (_tokenize_str (code ))
212+
213+ @set_config (
214+ check_fixme_in_docstring = True ,
215+ notes = ["CODETAG" ]
216+ )
217+ def test_docstring_custom_note (self ) -> None :
218+ code = """
219+ \" \" \"
220+ CODETAG implement this
221+ \" \" \"
222+ """
223+ with self .assertAddsMessages (
224+ MessageTest (msg_id = "fixme" , line = 3 , args = "CODETAG implement this" , col_offset = 9 ),
225+ ):
226+ self .checker .process_tokens (_tokenize_str (code ))
227+
228+ @set_config (
229+ check_fixme_in_docstring = True ,
230+ notes_rgx = "FIX.*"
231+ )
232+ def test_docstring_custom_rgx (self ) -> None :
233+ code = """
234+ \" \" \"
235+ FIXME implement this
236+ FIXTHIS also implement this
237+ \" \" \"
238+ """
239+ with self .assertAddsMessages (
240+ MessageTest (msg_id = "fixme" , line = 3 , args = "FIXME implement this" , col_offset = 9 ),
241+ MessageTest (msg_id = "fixme" , line = 4 , args = "FIXTHIS also implement this" , col_offset = 9 ),
242+ ):
243+ self .checker .process_tokens (_tokenize_str (code ))
0 commit comments