Skip to content

Use in-memory streams instead of NamedTemporaryFile. #9508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Lib/distutils/tests/test_log.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,9 +14,11 @@ def test_non_ascii(self):
# 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), \
Expand Down