From 18e053546c6798dc801956433087cafde9986121 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 20 Jan 2018 11:59:23 -0200 Subject: [PATCH] Use six.StringIO and __name__ in test_live_logging_suspends_capture --- testing/logging/test_reporting.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/testing/logging/test_reporting.py b/testing/logging/test_reporting.py index 0bd017057..4f605209c 100644 --- a/testing/logging/test_reporting.py +++ b/testing/logging/test_reporting.py @@ -460,13 +460,6 @@ def test_live_logging_suspends_capture(has_capture_manager, request): from _pytest.capture import CaptureManager from _pytest.logging import _LiveLoggingStreamHandler - if six.PY2: - # need to use the 'generic' StringIO instead of io.StringIO because we might receive both bytes - # and unicode objects; io.StringIO only accepts unicode - from StringIO import StringIO - else: - from io import StringIO - class MockCaptureManager: calls = [] @@ -481,11 +474,11 @@ def test_live_logging_suspends_capture(has_capture_manager, request): assert CaptureManager.resume_global_capture capture_manager = MockCaptureManager() if has_capture_manager else None - out_file = StringIO() + out_file = six.StringIO() handler = _LiveLoggingStreamHandler(out_file, capture_manager) - logger = logging.getLogger(__file__ + '.test_live_logging_suspends_capture') + logger = logging.getLogger(__name__ + '.test_live_logging_suspends_capture') logger.addHandler(handler) request.addfinalizer(partial(logger.removeHandler, handler))