Пример #1
0
def report(config):
    """Report fixture."""
    report_instance = ReportSingleton(config)
    yield report_instance
    save_path = config.get('save_path')
    if save_path:
        report_instance.save(save_path)
Пример #2
0
def pytest_terminal_summary(terminalreporter, exitstatus, config):
    """Write Interop Profile to terminal summary."""
    if config.getoption('collectonly'):
        return

    report = ReportSingleton(config.suite_config)

    if config.getoption('dev_notes'):
        terminalreporter.write('\n')
        terminalreporter.write_sep(
            '=', 'Developer Notes', bold=True
        )
        terminalreporter.write('\n')
        terminalreporter.write(report.notes_json())
        terminalreporter.write('\n')



    terminalreporter.write('\n')
    terminalreporter.write_sep(
        '=', 'Interop Profile', bold=True
    )
    terminalreporter.write('\n')
    terminalreporter.write(report.report_json())
    terminalreporter.write('\n')
Пример #3
0
def pytest_report_collectionfinish(config, startdir, items):
    """Print available tests if option set."""
    if config.getoption('list_tests'):
        reporter = config.pluginmanager.get_plugin('terminalreporter')
        reporter.write('\n')
        reporter.write_sep('-', 'Available Tests', bold=False, yellow=True)
        return ReportSingleton(config.suite_config).available_tests_json()
Пример #4
0
def pytest_terminal_summary(terminalreporter, exitstatus, config):
    """Write Interop Profile to terminal summary."""
    terminalreporter.write('\n')
    terminalreporter.write_sep('=', 'Interop Profile', bold=True, yellow=True)
    terminalreporter.write('\n')
    terminalreporter.write(ReportSingleton(config.suite_config).to_json())
    terminalreporter.write('\n')
Пример #5
0
def pytest_collection_modifyitems(session, config, items):
    """Select tests based on config or args."""
    # pylint: disable=protected-access
    if not items:
        return

    report = ReportSingleton(session.config.suite_config)

    def add_to_report(item):
        if callable(item._obj) and hasattr(item._obj, 'meta_set'):
            func = item._obj
            test_fn = TestFunction(
                protocol=func.protocol,
                version=func.version,
                role=func.role,
                name=func.name,
                description=func.__doc__
            )
            item.meta_name = test_fn.flatten()['name']
            report.add_test(test_fn)
        return item

    def test_regex_filter(item):
        for regex in config.tests_regex:
            if regex.match(item.meta_name):
                return True
        return False

    item_pipeline = map(add_to_report, items)
    if config.select_regex:
        item_pipeline = filter(
            lambda item: bool(config.select_regex.match(item.meta_name)),
            item_pipeline
        )
    elif config.tests_regex:
        item_pipeline = filter(
            test_regex_filter,
            item_pipeline
        )

    remaining = list(item_pipeline)
    deselected = set(items) - set(remaining)

    # Report the deselected items to pytest
    config.hook.pytest_deselected(items=deselected)

    items[:] = remaining