Skip to content

Commit

Permalink
Catch warning in test
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos committed Feb 29, 2024
1 parent 90fb70b commit 3702dfb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tests/test_deprecated_fields.py
@@ -1,4 +1,5 @@
import importlib.metadata
import warnings

import pytest
from packaging.version import Version
Expand Down Expand Up @@ -83,7 +84,10 @@ class Model(BaseModel):

@model_validator(mode='after')
def validate_x(self) -> Self:
self.x = self.x * 2
with warnings.catch_warnings():
warnings.simplefilter('error', DeprecationWarning)
self.x = self.x * 2
return self

instance = Model(x=1)

Expand Down

0 comments on commit 3702dfb

Please sign in to comment.