Skip to content

Commit 53d0b20

Browse files
committed
Add tests
1 parent 01b39d4 commit 53d0b20

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

tests/test_misc.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ def test_is_pydantic_model():
1515
class Model(BaseModel):
1616
x: int
1717

18+
class ModelNone(BaseModel):
19+
x: int | None
20+
1821
assert is_pydantic_model(Model)
1922
assert is_pydantic_model("instance") is False
23+
assert is_pydantic_model(ModelNone)
2024

2125

2226
def test_client():

tests/test_models.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class SomeModel(BaseModel):
99
i: int
1010
s: str
1111
f: float
12+
n: int | None = None
1213

1314

1415
class OtherModel(BaseModel):
@@ -86,7 +87,12 @@ def view7(request, obj: OtherModel = OtherModel(x=1, y=1)):
8687
(
8788
"/test1",
8889
dict(json={"i": "1", "s": "foo", "f": "1.1"}),
89-
{"i": 1, "s": "foo", "f": 1.1},
90+
{"i": 1, "s": "foo", "f": 1.1, "n": None},
91+
),
92+
(
93+
"/test1",
94+
dict(json={"i": "1", "s": "foo", "f": "1.1", "n": 42}),
95+
{"i": 1, "s": "foo", "f": 1.1, "n": 42},
9096
),
9197
(
9298
"/test2",
@@ -96,12 +102,15 @@ def view7(request, obj: OtherModel = OtherModel(x=1, y=1)):
96102
"other": {"x": 1, "y": 2},
97103
}
98104
),
99-
{"some": {"i": 1, "s": "foo", "f": 1.1}, "other": {"x": 1, "y": 2}},
105+
{
106+
"some": {"i": 1, "s": "foo", "f": 1.1, "n": None},
107+
"other": {"x": 1, "y": 2},
108+
},
100109
),
101110
(
102111
"/test3",
103112
dict(json={"i": "1", "s": "foo", "f": "1.1"}),
104-
{"i": 1, "s": "foo", "f": 1.1},
113+
{"i": 1, "s": "foo", "f": 1.1, "n": None},
105114
),
106115
(
107116
"/test_form",

0 commit comments

Comments
 (0)