You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As #2468 has mentioned, send_file opens a file that mean to be closed by some further processing of the WSGI server. However, test_client does not really run the WSGI server, causing the opened file not closed until all test ends, and thus triggers a ResourceWarning and causes cleaning code after a test request to fail.
Expected Behavior
A file opened by send_file() should be closed after response is sent.
The opened file is not closed properly after the response is sent, causing following code in the test fail to delete the file (which is temporarily generated for testing purpose).
......\test.py:22: ResourceWarning: unclosed file <_io.BufferedReader name='......\\test.txt'>
r = c.get(temp_file)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
......\case.py:704: ResourceWarning: unclosed file <_io.BufferedReader name='......\\test.txt'>
outcome.errors.clear()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
======================================================================
ERROR: test (__main__.Test) (i=1)
----------------------------------------------------------------------
Traceback (most recent call last):
File "......\test.py", line 25, in test
os.remove(temp_file)
PermissionError: [WinError 32] 程序無法存取檔案,因為檔案正由另一個程序使用。: '......\\test.txt'
======================================================================
ERROR: test (__main__.Test) (i=2)
----------------------------------------------------------------------
Traceback (most recent call last):
File "......\test.py", line 25, in test
os.remove(temp_file)
PermissionError: [WinError 32] 程序無法存取檔案,因為檔案正由另一個程序使用。: '......\\test.txt'
======================================================================
ERROR: test (__main__.Test) (i=3)
----------------------------------------------------------------------
Traceback (most recent call last):
File "......\test.py", line 25, in test
os.remove(temp_file)
PermissionError: [WinError 32] 程序無法存取檔案,因為檔案正由另一個程序使用。: '......\\test.txt'
----------------------------------------------------------------------
Ran 1 test in 0.010s
FAILED (errors=3)
Environment
Python version: 3.8.1
Flask version: 1.1.2
Werkzeug version: 1.0.1
The text was updated successfully, but these errors were encountered:
As #2468 has mentioned, send_file opens a file that mean to be closed by some further processing of the WSGI server. However, test_client does not really run the WSGI server, causing the opened file not closed until all test ends, and thus triggers a ResourceWarning and causes cleaning code after a test request to fail.
Expected Behavior
A file opened by send_file() should be closed after response is sent.
Actual Behavior
The opened file is not closed properly after the response is sent, causing following code in the test fail to delete the file (which is temporarily generated for testing purpose).
Environment
The text was updated successfully, but these errors were encountered: