summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-07-03 09:09:56 (GMT)
committerGitHub <noreply@github.com>2019-07-03 09:09:56 (GMT)
commitb71d8d67959f3b5efbdfe00066589ac0d8f98aad (patch)
tree8d1e014f3de495666fceccb81562b3a46182c18c /Lib
parent0f6f73ff3c2e46144884c4d418e67939a042aa23 (diff)
downloadcpython-b71d8d67959f3b5efbdfe00066589ac0d8f98aad.zip
cpython-b71d8d67959f3b5efbdfe00066589ac0d8f98aad.tar.gz
cpython-b71d8d67959f3b5efbdfe00066589ac0d8f98aad.tar.bz2
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.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_winconsoleio.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/Lib/test/test_winconsoleio.py b/Lib/test/test_winconsoleio.py
index a78fa4d..9a61e48 100644
--- a/Lib/test/test_winconsoleio.py
+++ b/Lib/test/test_winconsoleio.py
@@ -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)