Skip to content

Commit 2ac59b2

Browse files
committed
Fix tests
1 parent 0138621 commit 2ac59b2

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dependencies = [
1717
"tqdm > 4",
1818
"jiter>=0.10.0, <1",
1919
]
20-
requires-python = ">= 3.8"
20+
requires-python = ">= 3.9"
2121
classifiers = [
2222
"Typing :: Typed",
2323
"Intended Audience :: Developers",

tests/test_models.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from openai._utils import PropertyInfo
1111
from openai._compat import PYDANTIC_V1, parse_obj, model_dump, model_json
12-
from openai._models import BaseModel, construct_type
12+
from openai._models import BaseModel, construct_type, _DISCRIMINATOR_CACHE
1313

1414

1515
class BasicModel(BaseModel):
@@ -809,7 +809,7 @@ class B(BaseModel):
809809

810810
UnionType = cast(Any, Union[A, B])
811811

812-
assert not hasattr(UnionType, "__discriminator__")
812+
assert _DISCRIMINATOR_CACHE.get(UnionType) is None
813813

814814
m = construct_type(
815815
value={"type": "b", "data": "foo"}, type_=cast(Any, Annotated[UnionType, PropertyInfo(discriminator="type")])
@@ -818,7 +818,8 @@ class B(BaseModel):
818818
assert m.type == "b"
819819
assert m.data == "foo" # type: ignore[comparison-overlap]
820820

821-
discriminator = UnionType.__discriminator__
821+
discriminator = _DISCRIMINATOR_CACHE.get(UnionType)
822+
822823
assert discriminator is not None
823824

824825
m = construct_type(
@@ -830,7 +831,7 @@ class B(BaseModel):
830831

831832
# if the discriminator details object stays the same between invocations then
832833
# we hit the cache
833-
assert UnionType.__discriminator__ is discriminator
834+
assert _DISCRIMINATOR_CACHE.get(UnionType) is discriminator
834835

835836

836837
@pytest.mark.skipif(PYDANTIC_V1, reason="TypeAliasType is not supported in Pydantic v1")

0 commit comments

Comments
 (0)