Skip to content

Commit 5f7fac5

Browse files
Check documentation examples for fatal errors (#6475)
1 parent 8215901 commit 5f7fac5

File tree

7 files changed

+10
-3
lines changed

7 files changed

+10
-3
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Directly asserting a string literal will always pass.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
def test():
2-
# Nothing, as an assert of a string literal will always pass
2+
result = "result"
3+
expected = "expected"
4+
assert result == expected
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Directly asserting a string literal will always pass.

doc/data/messages/r/redundant-unittest-assert/good.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33

44
class DummyTestCase(unittest.TestCase):
55
def test_dummy(self):
6-
# Nothing, as an assert of a string literal will always pass
6+
actual = "test_result"
7+
self.assertEqual(actual, "expected")

doc/test_messages_documentation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def __init__(self, test_file: Tuple[str, Path]) -> None:
9191
args_list=[
9292
str(test_file[1]),
9393
"--disable=all",
94-
f"--enable={test_file[0]}",
94+
f"--enable={test_file[0]},astroid-error,fatal,syntax-error",
9595
],
9696
reporter=_test_reporter,
9797
config_file=config_file,

pylint/testutils/lint_module_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def __init__(
7171
# Always enable fatal errors
7272
messages_to_enable.add("astroid-error")
7373
messages_to_enable.add("fatal")
74+
messages_to_enable.add("syntax-error")
7475
args.extend(["--disable=all", f"--enable={','.join(messages_to_enable)}"])
7576
_config_initialization(
7677
self._linter, args_list=args, config_file=rc_file, reporter=_test_reporter

tests/testutils/test_functional_testutils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def test_minimal_messages_config_enabled(pytest_config) -> None:
6262
# Always enable fatal errors: important not to have false negatives
6363
"astroid-error",
6464
"fatal",
65+
"syntax-error",
6566
)
6667
)
6768
assert not mod_test._linter.is_message_enabled("unused-import")

0 commit comments

Comments
 (0)