From 60c0d19c9596856ee71fe6ce176ece52fa3c56b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Tue, 30 Jan 2024 13:03:23 +0100 Subject: [PATCH] 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 --- tests/test_validators.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/test_validators.py b/tests/test_validators.py index ba0c4969f6..33e2581d3e 100644 --- a/tests/test_validators.py +++ b/tests/test_validators.py @@ -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():