@@ -292,6 +292,62 @@ def test_log_2(fix):
292292 ])
293293
294294
295+ def test_live_logs_unknown_sections (testdir , request ):
296+ """Check that with live logging enable we are printing the correct headers during
297+ start/setup/call/teardown/finish."""
298+ filename = request .node .name + '.py'
299+ testdir .makeconftest ('''
300+ import pytest
301+ import logging
302+
303+ def pytest_runtest_protocol(item, nextitem):
304+ logging.warning('Unknown Section!')
305+
306+ def pytest_runtest_logstart():
307+ logging.warning('>>>>> START >>>>>')
308+
309+ def pytest_runtest_logfinish():
310+ logging.warning('<<<<< END <<<<<<<')
311+ ''' )
312+
313+ testdir .makepyfile ('''
314+ import pytest
315+ import logging
316+
317+ @pytest.fixture
318+ def fix(request):
319+ logging.warning("log message from setup of {}".format(request.node.name))
320+ yield
321+ logging.warning("log message from teardown of {}".format(request.node.name))
322+
323+ def test_log_1(fix):
324+ logging.warning("log message from test_log_1")
325+
326+ ''' )
327+ testdir .makeini ('''
328+ [pytest]
329+ log_cli=true
330+ ''' )
331+
332+ result = testdir .runpytest ()
333+ result .stdout .fnmatch_lines ([
334+ '*WARNING*Unknown Section*' ,
335+ '{}::test_log_1 ' .format (filename ),
336+ '*-- live log start --*' ,
337+ '*WARNING* >>>>> START >>>>>*' ,
338+ '*-- live log setup --*' ,
339+ '*WARNING*log message from setup of test_log_1*' ,
340+ '*-- live log call --*' ,
341+ '*WARNING*log message from test_log_1*' ,
342+ 'PASSED *100%*' ,
343+ '*-- live log teardown --*' ,
344+ '*WARNING*log message from teardown of test_log_1*' ,
345+ '*-- live log finish --*' ,
346+ '*WARNING* <<<<< END <<<<<<<*' ,
347+ '=* 1 passed in *=' ,
348+ ])
349+
350+
295351def test_log_cli_level (testdir ):
296352 # Default log file level
297353 testdir .makepyfile ('''
0 commit comments