def pytest_sessionfinish(session, exitstatus): c = collections.Counter() for test in test_tracking: c[_test_status(test)] += 1 # Prepend a total to the summary list results = ['total: {}'.format(sum(c.values())) ] + ['{}: {}'.format(k, v) for k, v in c.items()] # Then join it with commas summary = ', '.join(results) logger().info(log.format_marker('Finished test run', mark='=')) logger().info(log.format_marker(str(summary), mark='='))
def pytest_runtest_setup(item): path, lineno, domaininfo = item.location # @UnusedVariable logger().info(log.format_marker(_format_nodeid(item.nodeid), mark="-"), extra={ 'source_file': path, 'source_lineno': lineno }) yield
def pytest_runtest_logreport(self, report): # e.g. test_tracking['test_name']['setup'] = 'passed' # test_tracking['test_name']['call'] = 'skipped' # test_tracking['test_name']['teardown'] = 'failed' yield test_tracking[_format_nodeid(report.nodeid, False)][report.when] = report.outcome if report.when == 'teardown': path, lineno, domaininfo = report.location # @UnusedVariable test_status = _test_status(_format_nodeid(report.nodeid, False)) logger().info(log.format_marker('{} result: {}'.format( _format_nodeid(report.nodeid), test_status)), extra={ 'source_file': path, 'source_lineno': lineno }) if report.outcome == "skipped": logger().info(log.format_marker(report.longreprtext))
def pytest_collection_modifyitems(session, config, items): logger().info(log.format_marker('Starting new test run', mark="=")) expression = config.getvalue('keyword') or False expr_string = ', will filter with "{}"'.format( expression) if expression else '' logger().info('Collected {} items{}'.format(len(items), expr_string))