11# SPDX-FileCopyrightText: David Fritzsche
22# SPDX-License-Identifier: CC0-1.0
33
4+ from typing import Optional
5+
46import pytest
57
68from pytest_mypy_testing .message import Message , Severity
@@ -14,26 +16,35 @@ def test_init_severity(string: str, expected: Severity):
1416
1517
1618@pytest .mark .parametrize (
17- "filename,comment,severity,message" ,
19+ "filename,comment,severity,message,error_code " ,
1820 [
19- ("z.py" , "# E: bar" , Severity .ERROR , "bar" ),
20- ("z.py" , "#type:ignore# W: bar" , Severity .WARNING , "bar" ),
21- ("z.py" , "# type: ignore # W: bar" , Severity .WARNING , "bar" ),
22- ("z.py" , "# R: bar" , Severity .NOTE , "Revealed type is 'bar'" ),
21+ ("z.py" , "# E: bar" , Severity .ERROR , "bar" , None ),
22+ ("z.py" , "# E: bar" , Severity .ERROR , "bar" , "foo" ),
23+ ("z.py" , "# E: bar [foo]" , Severity .ERROR , "bar" , "foo" ),
24+ ("z.py" , "# E: bar [foo]" , Severity .ERROR , "bar" , "" ),
25+ ("z.py" , "#type:ignore# W: bar" , Severity .WARNING , "bar" , None ),
26+ ("z.py" , "# type: ignore # W: bar" , Severity .WARNING , "bar" , None ),
27+ ("z.py" , "# R: bar" , Severity .NOTE , "Revealed type is 'bar'" , None ),
2328 ],
2429)
2530def test_message_from_comment (
26- filename : str , comment : str , severity : Severity , message : str
31+ filename : str ,
32+ comment : str ,
33+ severity : Severity ,
34+ message : str ,
35+ error_code : Optional [str ],
2736):
2837 lineno = 123
38+ actual = Message .from_comment (filename , lineno , comment )
2939 expected = Message (
3040 filename = filename ,
3141 lineno = lineno ,
3242 colno = None ,
3343 severity = severity ,
3444 message = message ,
45+ error_code = error_code ,
3546 )
36- assert Message . from_comment ( filename , lineno , comment ) == expected
47+ assert actual == expected
3748
3849
3950def test_message_from_invalid_comment ():
0 commit comments