Use six.StringIO and __name__ in test_live_logging_suspends_capture
This commit is contained in:
parent
9dbcac9af3
commit
18e053546c
|
@ -460,13 +460,6 @@ def test_live_logging_suspends_capture(has_capture_manager, request):
|
||||||
from _pytest.capture import CaptureManager
|
from _pytest.capture import CaptureManager
|
||||||
from _pytest.logging import _LiveLoggingStreamHandler
|
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:
|
class MockCaptureManager:
|
||||||
calls = []
|
calls = []
|
||||||
|
|
||||||
|
@ -481,11 +474,11 @@ def test_live_logging_suspends_capture(has_capture_manager, request):
|
||||||
assert CaptureManager.resume_global_capture
|
assert CaptureManager.resume_global_capture
|
||||||
|
|
||||||
capture_manager = MockCaptureManager() if has_capture_manager else None
|
capture_manager = MockCaptureManager() if has_capture_manager else None
|
||||||
out_file = StringIO()
|
out_file = six.StringIO()
|
||||||
|
|
||||||
handler = _LiveLoggingStreamHandler(out_file, capture_manager)
|
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)
|
logger.addHandler(handler)
|
||||||
request.addfinalizer(partial(logger.removeHandler, handler))
|
request.addfinalizer(partial(logger.removeHandler, handler))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue