Commit b71d8d67 authored by Victor Stinner's avatar Victor Stinner Committed by GitHub

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.
parent 0f6f73ff
...@@ -25,14 +25,12 @@ class WindowsConsoleIOTests(unittest.TestCase): ...@@ -25,14 +25,12 @@ class WindowsConsoleIOTests(unittest.TestCase):
self.assertRaisesRegex(ValueError, self.assertRaisesRegex(ValueError,
"negative file descriptor", ConIO, -1) "negative file descriptor", ConIO, -1)
fd, _ = tempfile.mkstemp() with tempfile.TemporaryFile() as tmpfile:
try: fd = tmpfile.fileno()
# Windows 10: "Cannot open non-console file" # Windows 10: "Cannot open non-console file"
# Earlier: "Cannot open console output buffer for reading" # Earlier: "Cannot open console output buffer for reading"
self.assertRaisesRegex(ValueError, self.assertRaisesRegex(ValueError,
"Cannot open (console|non-console file)", ConIO, fd) "Cannot open (console|non-console file)", ConIO, fd)
finally:
os.close(fd)
try: try:
f = ConIO(0) f = ConIO(0)
......
test_winconsoleio doesn't leak a temporary file anymore: use
tempfile.TemporaryFile() to remove it when the test completes.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment