Skip to content

Commit

Permalink
Bring test_live_logs_unknown_sections directly due to merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoddemus committed Feb 17, 2018
1 parent fa8354e commit dfbaa20
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions testing/logging/test_reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,60 @@ def test_log_2(fix):
])


def test_live_logs_unknown_sections(testdir, request):
"""Check that with live logging enable we are printing the correct headers during
start/setup/call/teardown/finish."""
filename = request.node.name + '.py'
testdir.makeconftest('''
import pytest
import logging
def pytest_runtest_protocol(item, nextitem):
logging.warning('Unknown Section!')
def pytest_runtest_logstart():
logging.warning('>>>>> START >>>>>')
def pytest_runtest_logfinish():
logging.warning('<<<<< END <<<<<<<')
''')

testdir.makepyfile('''
import pytest
import logging
@pytest.fixture
def fix(request):
logging.warning("log message from setup of {}".format(request.node.name))
yield
logging.warning("log message from teardown of {}".format(request.node.name))
def test_log_1(fix):
logging.warning("log message from test_log_1")
''')
testdir.makeini('''
[pytest]
log_cli=true
''')

result = testdir.runpytest()
result.stdout.fnmatch_lines([
'*WARNING*Unknown Section*',
'{}::test_log_1 '.format(filename),
'*WARNING* >>>>> START >>>>>*',
'*-- live log setup --*',
'*WARNING*log message from setup of test_log_1*',
'*-- live log call --*',
'*WARNING*log message from test_log_1*',
'PASSED *100%*',
'*-- live log teardown --*',
'*WARNING*log message from teardown of test_log_1*',
'*WARNING* <<<<< END <<<<<<<*',
'=* 1 passed in *=',
])


def test_sections_single_new_line_after_test_outcome(testdir, request):
"""Check that only a single new line is written between log messages during
teardown/finish."""
Expand Down

0 comments on commit dfbaa20

Please sign in to comment.