summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-09-23 14:10:07 +0300
committerGitHub <noreply@github.com>2018-09-23 14:10:07 +0300
commita23e74ec65eaca077c3e8f21d592823c821e98f6 (patch)
tree7e7eb3f99e6c2d4b92189a34898624fd0fbb3c30
parent323ff835845c6b4e7e8a8e004f5ad4eaf878e4d8 (diff)
downloadpython-setuptools-git-a23e74ec65eaca077c3e8f21d592823c821e98f6.tar.gz
Use in-memory streams instead of NamedTemporaryFile. (GH-9508)
-rw-r--r--tests/test_log.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/tests/test_log.py b/tests/test_log.py
index 22c26246..75cf9006 100644
--- a/tests/test_log.py
+++ b/tests/test_log.py
@@ -1,8 +1,8 @@
"""Tests for distutils.log"""
+import io
import sys
import unittest
-from tempfile import NamedTemporaryFile
from test.support import swap_attr, run_unittest
from distutils import log
@@ -14,9 +14,11 @@ class TestLog(unittest.TestCase):
# output as is.
for errors in ('strict', 'backslashreplace', 'surrogateescape',
'replace', 'ignore'):
- with self.subTest(errors=errors), \
- NamedTemporaryFile("w+", encoding='cp437', errors=errors) as stdout, \
- NamedTemporaryFile("w+", encoding='cp437', errors=errors) as stderr:
+ with self.subTest(errors=errors):
+ stdout = io.TextIOWrapper(io.BytesIO(),
+ encoding='cp437', errors=errors)
+ stderr = io.TextIOWrapper(io.BytesIO(),
+ encoding='cp437', errors=errors)
old_threshold = log.set_threshold(log.DEBUG)
try:
with swap_attr(sys, 'stdout', stdout), \