fix: close TestClient properly in auth_client fixture to prevent gzip cleanup errors
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user