Browse Source

simplify test, ensure it fails on master

pull/15101/head
svlandeg 4 months ago
parent
commit
c4127224fd
  1. 11
      tests/test_jsonable_encoder.py

11
tests/test_jsonable_encoder.py

@ -321,16 +321,11 @@ def test_encode_pydantic_undefined():
pytest.param("pydantic_extra_types.color"),
],
)
def test_color_encoder(module_path):
def test_encode_color(module_path):
try:
Color = __import__(module_path, fromlist=["Color"]).Color
except ImportError:
pytest.skip(f"{module_path} not available")
class ModelWithColors(BaseModel):
color: Color
model_config = {"arbitrary_types_allowed": True}
obj = ModelWithColors(color=Color("blue"))
encoded = jsonable_encoder(obj)
assert encoded == {"color": "blue"}
data = {"color": Color("blue")}
assert jsonable_encoder(data) == {"color": "blue"}

Loading…
Cancel
Save