Coverage for tests / test_orjson_response_class.py: 100%

20 statements  

« prev     ^ index     » next       coverage.py v7.13.3, created at 2026-04-06 01:24 +0000

1import warnings 1abcd

2 

3from fastapi import FastAPI 1abcd

4from fastapi.exceptions import FastAPIDeprecationWarning 1abcd

5from fastapi.responses import ORJSONResponse 1abcd

6from fastapi.testclient import TestClient 1abcd

7from sqlalchemy.sql.elements import quoted_name 1abcd

8 

9with warnings.catch_warnings(): 1abcd

10 warnings.simplefilter("ignore", FastAPIDeprecationWarning) 1abcd

11 app = FastAPI(default_response_class=ORJSONResponse) 1abcd

12 

13 

14@app.get("/orjson_non_str_keys") 1abcd

15def get_orjson_non_str_keys(): 1abcd

16 key = quoted_name(value="msg", quote=False) 1efgh

17 return {key: "Hello World", 1: 1} 1efgh

18 

19 

20client = TestClient(app) 1abcd

21 

22 

23def test_orjson_non_str_keys(): 1abcd

24 with warnings.catch_warnings(): 1efgh

25 warnings.simplefilter("ignore", FastAPIDeprecationWarning) 1efgh

26 with client: 1efgh

27 response = client.get("/orjson_non_str_keys") 1efgh

28 assert response.json() == {"msg": "Hello World", "1": 1} 1efgh