summaryrefslogtreecommitdiff
path: root/tests/test_pragma_parser.py
diff options
context:
space:
mode:
authorDaniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>2021-09-04 18:52:55 +0200
committerGitHub <noreply@github.com>2021-09-04 18:52:55 +0200
commit25000863761220c1aa5db129e3cd41f5fe51b167 (patch)
treed211e4464a8aef25f969adffe7ba7cb6df8b8981 /tests/test_pragma_parser.py
parent6c818310fd0e2396b6333ad623da577bf84e361e (diff)
downloadpylint-git-25000863761220c1aa5db129e3cd41f5fe51b167.tar.gz
Add typing with `PyAnnotate` to `./tests` (#4950)
* Add mypy_extensions to requirement for ``NoReturn`` Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Diffstat (limited to 'tests/test_pragma_parser.py')
-rw-r--r--tests/test_pragma_parser.py36
1 files changed, 24 insertions, 12 deletions
diff --git a/tests/test_pragma_parser.py b/tests/test_pragma_parser.py
index 0dec8ac88..473f2048b 100644
--- a/tests/test_pragma_parser.py
+++ b/tests/test_pragma_parser.py
@@ -8,41 +8,46 @@ from pylint.utils.pragma_parser import (
)
-def test_simple_pragma():
+def test_simple_pragma() -> None:
comment = "#pylint: disable = missing-docstring"
match = OPTION_PO.search(comment)
+ assert match
for pragma_repr in parse_pragma(match.group(2)):
assert pragma_repr.action == "disable"
assert pragma_repr.messages == ["missing-docstring"]
-def test_disable_checker_with_number_in_name():
+def test_disable_checker_with_number_in_name() -> None:
comment = "#pylint: disable = j3-custom-checker"
match = OPTION_PO.search(comment)
+ assert match
for pragma_repr in parse_pragma(match.group(2)):
assert pragma_repr.action == "disable"
assert pragma_repr.messages == ["j3-custom-checker"]
-def test_simple_pragma_no_messages():
+def test_simple_pragma_no_messages() -> None:
comment = "#pylint: skip-file"
match = OPTION_PO.search(comment)
+ assert match
for pragma_repr in parse_pragma(match.group(2)):
assert pragma_repr.action == "skip-file"
assert pragma_repr.messages == []
-def test_simple_pragma_multiple_messages():
+def test_simple_pragma_multiple_messages() -> None:
comment = "#pylint: disable = missing-docstring, invalid-name"
match = OPTION_PO.search(comment)
+ assert match
for pragma_repr in parse_pragma(match.group(2)):
assert pragma_repr.action == "disable"
assert pragma_repr.messages == ["missing-docstring", "invalid-name"]
-def test_multiple_pragma_multiple_messages():
+def test_multiple_pragma_multiple_messages() -> None:
comment = "#pylint: disable = missing-docstring, invalid-name, enable = R0202, no-self-use"
match = OPTION_PO.search(comment)
+ assert match
res = list(parse_pragma(match.group(2)))
assert res[0].action == "disable"
assert res[0].messages == ["missing-docstring", "invalid-name"]
@@ -50,51 +55,58 @@ def test_multiple_pragma_multiple_messages():
assert res[1].messages == ["R0202", "no-self-use"]
-def test_missing_assignment():
+def test_missing_assignment() -> None:
comment = "#pylint: disable missing-docstring"
match = OPTION_PO.search(comment)
+ assert match
with pytest.raises(InvalidPragmaError):
list(parse_pragma(match.group(2)))
-def test_missing_keyword():
+def test_missing_keyword() -> None:
comment = "#pylint: = missing-docstring"
match = OPTION_PO.search(comment)
+ assert match
with pytest.raises(InvalidPragmaError):
list(parse_pragma(match.group(2)))
-def test_unsupported_assignment():
+def test_unsupported_assignment() -> None:
comment = "#pylint: disable-all = missing-docstring"
match = OPTION_PO.search(comment)
+ assert match
with pytest.raises(UnRecognizedOptionError):
list(parse_pragma(match.group(2)))
-def test_unknown_keyword_with_messages():
+def test_unknown_keyword_with_messages() -> None:
comment = "#pylint: unknown-keyword = missing-docstring"
match = OPTION_PO.search(comment)
+ assert match
with pytest.raises(UnRecognizedOptionError):
list(parse_pragma(match.group(2)))
-def test_unknown_keyword_without_messages():
+def test_unknown_keyword_without_messages() -> None:
comment = "#pylint: unknown-keyword"
match = OPTION_PO.search(comment)
+ assert match
with pytest.raises(UnRecognizedOptionError):
list(parse_pragma(match.group(2)))
-def test_missing_message():
+def test_missing_message() -> None:
comment = "#pylint: disable = "
match = OPTION_PO.search(comment)
+ assert match
with pytest.raises(InvalidPragmaError):
list(parse_pragma(match.group(2)))
-def test_parse_message_with_dash():
+def test_parse_message_with_dash() -> None:
comment = "#pylint: disable = raw_input-builtin"
match = OPTION_PO.search(comment)
+ assert match
res = list(parse_pragma(match.group(2)))
assert res[0].action == "disable"
assert res[0].messages == ["raw_input-builtin"]