From: Sam Mirazi Date: Sun, 1 Jun 2025 06:53:33 +0000 (-0700) Subject: End of phase 4 X-Git-Url: https://git.josue.xyz/?a=commitdiff_plain;h=c013324c362027ed3a5fe8e04b6534c452d68193;p=fastapi-vs-flask%2F.git End of phase 4 --- diff --git a/tests/__pycache__/test_fastapi_route.cpython-312-pytest-8.3.5.pyc b/tests/__pycache__/test_fastapi_route.cpython-312-pytest-8.3.5.pyc index d591117..7c2c6ff 100644 Binary files a/tests/__pycache__/test_fastapi_route.cpython-312-pytest-8.3.5.pyc and b/tests/__pycache__/test_fastapi_route.cpython-312-pytest-8.3.5.pyc differ diff --git a/tests/__pycache__/test_fastapi_route.cpython-312.pyc b/tests/__pycache__/test_fastapi_route.cpython-312.pyc index 0dc75b3..f484d07 100644 Binary files a/tests/__pycache__/test_fastapi_route.cpython-312.pyc and b/tests/__pycache__/test_fastapi_route.cpython-312.pyc differ diff --git a/tests/__pycache__/test_flask_route.cpython-312-pytest-8.3.5.pyc b/tests/__pycache__/test_flask_route.cpython-312-pytest-8.3.5.pyc index 5dbc354..47271f6 100644 Binary files a/tests/__pycache__/test_flask_route.cpython-312-pytest-8.3.5.pyc and b/tests/__pycache__/test_flask_route.cpython-312-pytest-8.3.5.pyc differ diff --git a/tests/test_fastapi_route.py b/tests/test_fastapi_route.py index 40ff1d2..f6e646a 100644 --- a/tests/test_fastapi_route.py +++ b/tests/test_fastapi_route.py @@ -6,6 +6,7 @@ import uvicorn import threading import time from multiprocessing import Process # Using Process for better isolation +import os # Server configuration HOST = "127.0.0.1" @@ -30,12 +31,16 @@ class UvicornServer(threading.Thread): # UvicornServer using Process for cleaner start/stop # This might be more robust for test isolation. -def run_server_process(app_module_str, host, port): +def run_server_process(app_module_str, host, port, project_root_dir): + # Add project root to Python path for the new process + import sys + sys.path.insert(0, project_root_dir) uvicorn.run(app_module_str, host=host, port=port, log_level="warning") async def start_server_fastapi(): + project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) # Using Process to run Uvicorn. This provides better isolation and cleanup. - proc = Process(target=run_server_process, args=("app_fastapi.app:app", HOST, PORT), daemon=True) + proc = Process(target=run_server_process, args=("app_fastapi.app:app", HOST, PORT, project_root), daemon=True) proc.start() await asyncio.sleep(2.0) # Increased sleep to ensure server is fully up if not proc.is_alive():