mirror of
https://github.com/python/cpython.git
synced 2025-11-12 07:02:33 +00:00
Use in-memory streams instead of NamedTemporaryFile. (GH-9508)
This commit is contained in:
parent
17b1d5d4e3
commit
24b447edf2
1 changed files with 6 additions and 4 deletions
|
|
@ -1,8 +1,8 @@
|
||||||
"""Tests for distutils.log"""
|
"""Tests for distutils.log"""
|
||||||
|
|
||||||
|
import io
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
from tempfile import NamedTemporaryFile
|
|
||||||
from test.support import swap_attr, run_unittest
|
from test.support import swap_attr, run_unittest
|
||||||
|
|
||||||
from distutils import log
|
from distutils import log
|
||||||
|
|
@ -14,9 +14,11 @@ class TestLog(unittest.TestCase):
|
||||||
# output as is.
|
# output as is.
|
||||||
for errors in ('strict', 'backslashreplace', 'surrogateescape',
|
for errors in ('strict', 'backslashreplace', 'surrogateescape',
|
||||||
'replace', 'ignore'):
|
'replace', 'ignore'):
|
||||||
with self.subTest(errors=errors), \
|
with self.subTest(errors=errors):
|
||||||
NamedTemporaryFile("w+", encoding='cp437', errors=errors) as stdout, \
|
stdout = io.TextIOWrapper(io.BytesIO(),
|
||||||
NamedTemporaryFile("w+", encoding='cp437', errors=errors) as stderr:
|
encoding='cp437', errors=errors)
|
||||||
|
stderr = io.TextIOWrapper(io.BytesIO(),
|
||||||
|
encoding='cp437', errors=errors)
|
||||||
old_threshold = log.set_threshold(log.DEBUG)
|
old_threshold = log.set_threshold(log.DEBUG)
|
||||||
try:
|
try:
|
||||||
with swap_attr(sys, 'stdout', stdout), \
|
with swap_attr(sys, 'stdout', stdout), \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue