Skip to content

Commit a7db6e8

Browse files
committed
lost changes in one test
1 parent 916faf0 commit a7db6e8

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

tests/tornado/test_tornado_integration.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import json
2-
31
from pydantic import BaseModel
2+
from pydantic_core import from_json, to_json
43
from tornado.testing import AsyncHTTPTestCase, gen_test
54
from tornado.web import Application, HTTPError
65

@@ -110,7 +109,7 @@ async def delete_item(item_id: int):
110109
return app
111110

112111
def parse_json(self, response):
113-
return json.loads(response.body.decode())
112+
return from_json(response.body.decode())
114113

115114
@gen_test
116115
async def test_get_items(self):
@@ -174,7 +173,7 @@ async def test_get_nonexistent_item(self):
174173
@gen_test
175174
async def test_create_item(self):
176175
new_item = {"name": "New Item", "description": "New Description"}
177-
body = json.dumps(new_item).encode()
176+
body = to_json(new_item).decode("utf-8")
178177
headers = {"Content-Type": "application/json"}
179178
response = await self.http_client.fetch(
180179
self.get_url("/items"),
@@ -191,7 +190,7 @@ async def test_create_item(self):
191190
@gen_test
192191
async def test_create_item_incorrect(self):
193192
new_item = {"name": None, "description": "New Description"}
194-
body = json.dumps(new_item).encode()
193+
body = to_json(new_item).decode("utf-8")
195194
headers = {"Content-Type": "application/json"}
196195
response = await self.http_client.fetch(
197196
self.get_url("/items"),
@@ -223,7 +222,7 @@ async def test_create_item_invalid_json(self):
223222
@gen_test
224223
async def test_update_item(self):
225224
update_data = {"name": "Updated Item"}
226-
body = json.dumps(update_data).encode()
225+
body = to_json(update_data).decode("utf-8")
227226
headers = {"Content-Type": "application/json"}
228227
response = await self.http_client.fetch(
229228
self.get_url("/items/2"),
@@ -240,7 +239,7 @@ async def test_update_item(self):
240239
@gen_test
241240
async def test_update_full_item(self):
242241
update_data = {"name": "Updated Item", "description": "Updated Description"}
243-
body = json.dumps(update_data).encode()
242+
body = to_json(update_data).decode("utf-8")
244243
headers = {"Content-Type": "application/json"}
245244
response = await self.http_client.fetch(
246245
self.get_url("/items/2"),

0 commit comments

Comments
 (0)