Skip to content

Commit

Permalink
Fail pytest runs on warnings (#7809)
Browse files Browse the repository at this point in the history
* Catch DeprecationWarning in pyreverse

Follow-up to #6869

* Patch use of deprecated `astroid.node_classes` in test

* Ignore DeprecationWarning in test_parseable_output_regression

Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
  • Loading branch information
jacobtylerwalls and Pierre-Sassoulas committed Nov 23, 2022
1 parent e2ef840 commit 694d302
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ test = "pytest"
testpaths = ["tests"]
python_files = ["*test_*.py"]
addopts = "--strict-markers"
filterwarnings = "error"
markers = [
"primer_stdlib: Checks for crashes and errors when running pylint on stdlib",
"primer_external_batch_one: Checks for crashes and errors when running pylint on external libs (batch one)",
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/b/bad_reversed_sequence_py37.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
bad-reversed-sequence:5:::The first reversed() argument is not a sequence
bad-reversed-sequence:12:::The first reversed() argument is not a sequence
bad-reversed-sequence:5:0:5:26::The first reversed() argument is not a sequence:UNDEFINED
bad-reversed-sequence:12:0:12:39::The first reversed() argument is not a sequence:UNDEFINED
Original file line number Diff line number Diff line change
@@ -1 +1 @@
star-needs-assignment-target:15:37::Can use starred expression only in assignment target
star-needs-assignment-target:15:36:15:46::Can use starred expression only in assignment target:UNDEFINED
5 changes: 4 additions & 1 deletion tests/pyreverse/test_inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from __future__ import annotations

import os
import warnings
from collections.abc import Generator
from pathlib import Path

Expand All @@ -30,7 +31,9 @@ def project(get_project: GetProjectCallable) -> Generator[Project, None, None]:
with _test_cwd(TESTS):
project = get_project("data", "data")
linker = inspector.Linker(project)
linker.visit(project)
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
linker.visit(project)
yield project


Expand Down
2 changes: 1 addition & 1 deletion tests/pyreverse/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def test_infer_node_1(mock_infer: Any, mock_get_annotation: Any) -> None:


@patch("pylint.pyreverse.utils.get_annotation")
@patch("astroid.node_classes.NodeNG.infer")
@patch("astroid.nodes.NodeNG.infer")
def test_infer_node_2(mock_infer: Any, mock_get_annotation: Any) -> None:
"""Return set(node.infer()) when InferenceError is not raised and an
annotation has not been returned
Expand Down
1 change: 1 addition & 0 deletions tests/reporters/unittest_reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def test_parseable_output_deprecated() -> None:
def test_parseable_output_regression() -> None:
output = StringIO()
with warnings.catch_warnings(record=True):
warnings.simplefilter("ignore", category=DeprecationWarning)
linter = PyLinter(reporter=ParseableTextReporter())

checkers.initialize(linter)
Expand Down

0 comments on commit 694d302

Please sign in to comment.