8000 Fix test failures with pytest-8.0.0 due to `pytest.warns()` starting to work inside `pytest.raises()` by mgorny · Pull Request #8678 · pydantic/pydantic · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix test_use_no_fields() not to assert for non-emitted warning
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 #8674
  • Loading branch information
mgorny committed Jan 30, 2024
commit 60c0d19c9596856ee71fe6ce176ece52fa3c56b9
8 changes: 3 additions & 5 deletions tests/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,11 +556,9 @@ def test_use_no_fields():
class Model(BaseModel):
a: str

with pytest.warns(PydanticDeprecatedSince20, match=V1_VALIDATOR_DEPRECATION_MATCH):

@validator()
def checker(cls, v):
return v
@validator()
def checker(cls, v):
return v


def test_use_no_fields_field_validator():
Expand Down
0