Skip to content

Commit

Permalink
epoch - fix related tests
Browse files Browse the repository at this point in the history
  • Loading branch information
commonism committed Nov 29, 2024
1 parent 64e1710 commit 1615fcb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/ref_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,23 @@ def test_allOf_resolution(petstore_expanded):
pass
items = pet.model_fields

assert sorted(items.keys()) == ["id", "name", "tag"]
assert sorted(items.keys()) == ["created", "id", "name", "tag"]

def is_nullable(x):
# Optional[…] or | None
return typing.get_origin(x.annotation) == typing.Union and type(None) in typing.get_args(x.annotation)

assert sorted(map(lambda x: x[0], filter(lambda y: is_nullable(y[1]), items.items()))) == sorted(
["tag"]
), ref.schema()
["created", "tag"]
), ref.model_json_schema()

def is_required(x):
# not assign a default '= Field(default=…)' or '= …'
return x.default == pydantic_core.PydanticUndefined

assert sorted(map(lambda x: x[0], filter(lambda y: is_required(y[1]), items.items()))) == sorted(
["id", "name"]
), ref.schema()
), ref.model_json_schema()

assert items["id"].annotation == int
assert items["name"].annotation == str
Expand Down

0 comments on commit 1615fcb

Please sign in to comment.