Skip to content

Commit

Permalink
Check documentation examples for fatal errors (#6475)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls authored Apr 30, 2022
1 parent 8215901 commit 5f7fac5
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions doc/data/messages/a/assert-on-string-literal/details.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Directly asserting a string literal will always pass.
4 changes: 3 additions & 1 deletion doc/data/messages/a/assert-on-string-literal/good.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
def test():
# Nothing, as an assert of a string literal will always pass
result = "result"
expected = "expected"
assert result == expected
1 change: 1 addition & 0 deletions doc/data/messages/r/redundant-unittest-assert/details.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Directly asserting a string literal will always pass.
3 changes: 2 additions & 1 deletion doc/data/messages/r/redundant-unittest-assert/good.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@

class DummyTestCase(unittest.TestCase):
def test_dummy(self):
# Nothing, as an assert of a string literal will always pass
actual = "test_result"
self.assertEqual(actual, "expected")
2 changes: 1 addition & 1 deletion doc/test_messages_documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __init__(self, test_file: Tuple[str, Path]) -> None:
args_list=[
str(test_file[1]),
"--disable=all",
f"--enable={test_file[0]}",
f"--enable={test_file[0]},astroid-error,fatal,syntax-error",
],
reporter=_test_reporter,
config_file=config_file,
Expand Down
1 change: 1 addition & 0 deletions pylint/testutils/lint_module_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def __init__(
# Always enable fatal errors
messages_to_enable.add("astroid-error")
messages_to_enable.add("fatal")
messages_to_enable.add("syntax-error")
args.extend(["--disable=all", f"--enable={','.join(messages_to_enable)}"])
_config_initialization(
self._linter, args_list=args, config_file=rc_file, reporter=_test_reporter
Expand Down
1 change: 1 addition & 0 deletions tests/testutils/test_functional_testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def test_minimal_messages_config_enabled(pytest_config) -> None:
# Always enable fatal errors: important not to have false negatives
"astroid-error",
"fatal",
"syntax-error",
)
)
assert not mod_test._linter.is_message_enabled("unused-import")
Expand Down

0 comments on commit 5f7fac5

Please sign in to comment.