fix: close TestClient properly in auth_client fixture to prevent gzip cleanup errors
CI / lint (push) Successful in 14s
CI / security (push) Successful in 11s
CI / test (push) Failing after 23s
CI / build (push) Has been skipped

This commit is contained in:
2026-06-05 07:52:29 -04:00
parent ccb0fb3e97
commit a0cae4a6a4
4 changed files with 459 additions and 0 deletions
+6
View File
@@ -75,6 +75,12 @@ def auth_client():
from fastapi.testclient import TestClient
client = TestClient(app)
yield client
# Properly close the test client to flush gzip writers
# before the temp directory is removed
if hasattr(client, 'close'):
client.close()
# Give the event loop a chance to clean up pending callbacks
loop.run_until_complete(asyncio.sleep(0))
os.chdir(orig_cwd)
shutil.rmtree(str(tmp), ignore_errors=True)