Skip to content

Commit

Permalink
Fix test_use_no_fields() not to assert for non-emitted warning
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mgorny committed Jan 30, 2024
1 parent c1dff15 commit 60c0d19
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions tests/test_validators.py
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 comments on commit 60c0d19

Please sign in to comment.