summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_winconsoleio.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_winconsoleio.py')
-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)