Coverage for tests/test_orjson_response_class.py: 100%

14 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-12-04 08:29 +0000

1from fastapi import FastAPI 1abcdefg

2from fastapi.responses import ORJSONResponse 1abcdefg

3from fastapi.testclient import TestClient 1abcdefg

4from sqlalchemy.sql.elements import quoted_name 1abcdefg

5 

6app = FastAPI(default_response_class=ORJSONResponse) 1abcdefg

7 

8 

9@app.get("/orjson_non_str_keys") 1abcdefg

10def get_orjson_non_str_keys(): 1abcdefg

11 key = quoted_name(value="msg", quote=False) 1hijklmn

12 return {key: "Hello World", 1: 1} 1hijklmn

13 

14 

15client = TestClient(app) 1abcdefg

16 

17 

18def test_orjson_non_str_keys(): 1abcdefg

19 with client: 1hijklmn

20 response = client.get("/orjson_non_str_keys") 1hijklmn

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