conftest.py
1 import sys 2 sys.setrecursionlimit(50000) 3 4 # Force ALL Pydantic models to fully resolve their schemas in the main thread 5 # under the raised recursion limit. Without this, TestClient triggers schema 6 # resolution inside a thread pool where the recursion limit may not be sufficient. 7 import inspect 8 from restai.models import models as _models_module 9 from pydantic import BaseModel 10 11 for _name, _obj in inspect.getmembers(_models_module): 12 if inspect.isclass(_obj) and issubclass(_obj, BaseModel) and _obj is not BaseModel: 13 try: 14 _obj.model_rebuild() 15 except Exception: 16 pass