Browse Source

fixing the m

pull/14060/head
SaisakthiM 10 months ago
parent
commit
f35136bee7
  1. 11
      tests/test_color_compat.py

11
tests/test_color_compat.py

@ -1,4 +1,5 @@
import warnings
import pydantic
try:
@ -6,12 +7,18 @@ try:
except ImportError:
from pydantic.color import Color # triggers DeprecationWarning on v1
class Model(pydantic.BaseModel):
c: Color
def test_color_deprecation_warning():
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
Model(c="#FF0000")
dep_warnings = [warn for warn in w if issubclass(warn.category, DeprecationWarning)]
# instantiate to trigger warning
Model(c=Color("#FF0000"))
dep_warnings = [
warn for warn in w if issubclass(warn.category, DeprecationWarning)
]
assert len(dep_warnings) == 0, "DeprecationWarning raised! Fixed in this PR"

Loading…
Cancel
Save