Use six.StringIO and __name__ in test_live_logging_suspends_capture

This commit is contained in:
Bruno Oliveira 2018-01-20 11:59:23 -02:00
parent 9dbcac9af3
commit 18e053546c
1 changed files with 2 additions and 9 deletions

View File

@ -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))