mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
bpo-37421: test_winconsoleio doesn't leak temp file anymore (GH-14562)
test_winconsoleio doesn't leak a temporary file anymore: use
tempfile.TemporaryFile() to remove it when the test completes.
(cherry picked from commit b71d8d6795
)
Co-authored-by: Victor Stinner <vstinner@redhat.com>
This commit is contained in:
parent
b8e198a5d0
commit
a2a807f75d
2 changed files with 4 additions and 4 deletions
|
@ -25,14 +25,12 @@ class WindowsConsoleIOTests(unittest.TestCase):
|
|||
self.assertRaisesRegex(ValueError,
|
||||
"negative file descriptor", ConIO, -1)
|
||||
|
||||
fd, _ = tempfile.mkstemp()
|
||||
try:
|
||||
with tempfile.TemporaryFile() as tmpfile:
|
||||
fd = tmpfile.fileno()
|
||||
# Windows 10: "Cannot open non-console file"
|
||||
# Earlier: "Cannot open console output buffer for reading"
|
||||
self.assertRaisesRegex(ValueError,
|
||||
"Cannot open (console|non-console file)", ConIO, fd)
|
||||
finally:
|
||||
os.close(fd)
|
||||
|
||||
try:
|
||||
f = ConIO(0)
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
test_winconsoleio doesn't leak a temporary file anymore: use
|
||||
tempfile.TemporaryFile() to remove it when the test completes.
|
Loading…
Add table
Add a link
Reference in a new issue