Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Use in-memory stream instead of NamedTemporaryFile.
  • Loading branch information
serhiy-storchaka committed Sep 23, 2018
commit 8a961226e1f1ff60218965bab832b176bf72e88f
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