Skip to content

Commit 24b447e

Browse files
Use in-memory streams instead of NamedTemporaryFile. (GH-9508)
1 parent 17b1d5d commit 24b447e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Lib/distutils/tests/test_log.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""Tests for distutils.log"""
22

3+
import io
34
import sys
45
import unittest
5-
from tempfile import NamedTemporaryFile
66
from test.support import swap_attr, run_unittest
77

88
from distutils import log
@@ -14,9 +14,11 @@ def test_non_ascii(self):
1414
# output as is.
1515
for errors in ('strict', 'backslashreplace', 'surrogateescape',
1616
'replace', 'ignore'):
17-
with self.subTest(errors=errors), \
18-
NamedTemporaryFile("w+", encoding='cp437', errors=errors) as stdout, \
19-
NamedTemporaryFile("w+", encoding='cp437', errors=errors) as stderr:
17+
with self.subTest(errors=errors):
18+
stdout = io.TextIOWrapper(io.BytesIO(),
19+
encoding='cp437', errors=errors)
20+
stderr = io.TextIOWrapper(io.BytesIO(),
21+
encoding='cp437', errors=errors)
2022
old_threshold = log.set_threshold(log.DEBUG)
2123
try:
2224
with swap_attr(sys, 'stdout', stdout), \

0 commit comments

Comments
 (0)