Skip to content

Commit

Permalink
bpo-37421: test_winconsoleio doesn't leak temp file anymore (GH-14562)
Browse files Browse the repository at this point in the history
test_winconsoleio doesn't leak a temporary file anymore: use
tempfile.TemporaryFile() to remove it when the test completes.
  • Loading branch information
vstinner committed Jul 3, 2019
1 parent 0f6f73f commit b71d8d6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 2 additions & 4 deletions Lib/test/test_winconsoleio.py
Expand Up @@ -25,14 +25,12 @@ def test_open_fd(self):
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)
Expand Down
@@ -0,0 +1,2 @@
test_winconsoleio doesn't leak a temporary file anymore: use
tempfile.TemporaryFile() to remove it when the test completes.

0 comments on commit b71d8d6

Please sign in to comment.