@@ -272,6 +272,60 @@ def test_log_2(fix):
272272 ])
273273
274274
275+ def test_live_logs_unknown_sections (testdir , request ):
276+ """Check that with live logging enable we are printing the correct headers during
277+ start/setup/call/teardown/finish."""
278+ filename = request .node .name + '.py'
279+ testdir .makeconftest ('''
280+ import pytest
281+ import logging
282+
283+ def pytest_runtest_protocol(item, nextitem):
284+ logging.warning('Unknown Section!')
285+
286+ def pytest_runtest_logstart():
287+ logging.warning('>>>>> START >>>>>')
288+
289+ def pytest_runtest_logfinish():
290+ logging.warning('<<<<< END <<<<<<<')
291+ ''' )
292+
293+ testdir .makepyfile ('''
294+ import pytest
295+ import logging
296+
297+ @pytest.fixture
298+ def fix(request):
299+ logging.warning("log message from setup of {}".format(request.node.name))
300+ yield
301+ logging.warning("log message from teardown of {}".format(request.node.name))
302+
303+ def test_log_1(fix):
304+ logging.warning("log message from test_log_1")
305+
306+ ''' )
307+ testdir .makeini ('''
308+ [pytest]
309+ log_cli=true
310+ ''' )
311+
312+ result = testdir .runpytest ()
313+ result .stdout .fnmatch_lines ([
314+ '*WARNING*Unknown Section*' ,
315+ '{}::test_log_1 ' .format (filename ),
316+ '*WARNING* >>>>> START >>>>>*' ,
317+ '*-- live log setup --*' ,
318+ '*WARNING*log message from setup of test_log_1*' ,
319+ '*-- live log call --*' ,
320+ '*WARNING*log message from test_log_1*' ,
321+ 'PASSED *100%*' ,
322+ '*-- live log teardown --*' ,
323+ '*WARNING*log message from teardown of test_log_1*' ,
324+ '*WARNING* <<<<< END <<<<<<<*' ,
325+ '=* 1 passed in *=' ,
326+ ])
327+
328+
275329def test_log_cli_level (testdir ):
276330 # Default log file level
277331 testdir .makepyfile ('''
0 commit comments