-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fail pytest runs on warnings #7809
Fail pytest runs on warnings #7809
Conversation
862de2a
to
3a9d011
Compare
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really good catch here and sorry one of my PRs introduced a warning. Looks like now it's failing the test run with it! Let me know if you want to fix the warnings in this PR or you want me to intervene via another issue/ PR.
I have to look at this more closely this evening. Currently I don't see why this change should work as intended. |
@@ -89,6 +89,7 @@ test = "pytest" | |||
testpaths = ["tests"] | |||
python_files = ["*test_*.py"] | |||
addopts = "--strict-markers" | |||
filterwarnings = "error" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will this make pytest fail at any len(warnings) > 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep!
There's one pyreverse test that still makes use of |
If you have time to help, that would be great. You can either push to my branch (GH's own editor makes that easier than it used to) or open a new PR, whatever works ππ» |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Managed to squeeze the review in. As suspected the change does not help in this case, but I can understand the confusion (the Generator
return type together with TESTS
sounding like plural it seems like we are iterating over different directories here).
Let me know if you need more help!
tests/pyreverse/test_inspector.py
Outdated
@@ -30,7 +30,14 @@ 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) | |||
if "clientmodule_test" in str(project): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is never true, as the project
is always the same here (the data
directory underneath /tests
). The string representation of project
does not contain the substring clientmodule_test
.
I would suggest just get rid of the if
condition here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that, but I received many failures. I'll try again tonight. π€
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, but with the current change we are always hitting the else
, and nothing has changed effectively compared to before.
I haven't looked at how to actually properly catch the warning, my guess would be that there are some other tests that don't catch this Warning yet (the majority of the legacy tests for pyreverse
work with the same test data). I will also take a closer look at it this or tomorrow evening!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neither on your branch nor on main could I reproduce the deprecation warnings on the pyreverse
tests.
On a recent CI run there is only one DeprecationWarning
for some other test case, but not for pyreverse
.
Am I missing something here like an option I have to turn on first?
Edit: That's strange - If I only run pytest tests/pyreverse/test_inspector
I can see the DeprecationWarning
in the warnings summary
, but if I run pytest tests/pyreverse/
instead it does not appear. Maybe a bug in pytest
?
Edit 2: I have the feeling that if a specific DeprecationWarning
is caught and suppressed anywhere in the test suite using pytest.warns(DeprecationWarning)
, it will be suppressed for the whole remaining test suite as well.
While reading the docs I also found that it is possible to filter and ignore warnings for an entire test module via pytestmark = pytest.mark.filterwarnings("ignore:pyreverse:DeprecationWarning")
at the top of the file, which is more convenient than wrapping all .visit()
calls into with pytest.warns()
blocks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry @DudeNr33 you're quite right, the else
branch always executes. I've just pushed a change to just ignore warnings in this fixture.
Pull Request Test Coverage Report for Build 3528574134
π - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like no contributers used python 3.7 anymore :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in the discussion I think there is a bug in pytest
when it comes to suppress warnings, and if that's true and the bug gets resolved we may have to update more of the pyreverse
test files - but until then all fine from my side! π
Type of Changes
Description
I've opened a few PRs over time to clean up warnings in the test suite when I see them. Figured we might as well fail CI so that we don't merge with known issues.
Failure expected due to #7795, mentioned here: #7795 (comment). Edit: resolved.