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
Test regressions with pytest 8.0.0 #8674
Comments
For the record, I've seen a similar issue with one more package but here it looks it could actually be a pytest bug. I've gotta leave right now but I'll take another look when I get home. |
Ok, I think this is actually a bug in the test suite. pydantic/pydantic/deprecated/class_validators.py Lines 115 to 134 in c1dff15
Unless I'm missing something, the exception is thrown before the warning is emitted. pydantic/tests/test_validators.py Lines 529 to 539 in c1dff15
I'm guessing that with pytest-7, the |
I'm preparing a pull request to address at last some of the failures. |
Fix `tests/test_validators.py::test_use_no_fields` not to check for a warning that can't be emitted because calling the decorator fails with a `TypeError`. Starting with pytest 8.0.0 (due to pytest-dev/pytest#9036 fix), `pytest.warns()` assertions are enforced even if an exception is raised and consumed by `pytest.raises()`. Bug pydantic#8674
Emit Pydantic V1 style `@validator` deprecation warnings before raising `PydanticUserError` about incorrect use. This is one of the possible solutions to test failures introduced with pytest 8.0.0, as now `pytest.warns()` assertions are enforced even if an exception raised and caught by `pytest.raises()` (this is pytest-dev/pytest#9036). The alternate possibility would be to remove `pytest.warns()` from respective test functions but I think it's reasonable to emit these warnings, to warn the users that they ought to consider upgrading the code to Pydantic V2 API rather than fixing the immediate issue. Bug pydantic#8674
Initial Checks
Description
When running the test suite using
pytest 8.0.0
, the following test regressions are seen:Full output
Example Code
No response
Python, Pydantic & OS Version
The text was updated successfully, but these errors were encountered: