Skip to content

question: what is the plugin avoiding by only creating and registering the plugin class on the master node with xdist on? #22

@pharmon-duo

Description

@pharmon-duo

hey fruch!

i've been evaluating this plugin with a pet project. it works great when i'm not using xdist. but when i run my tests with -n=2, i get this error:

_ ERROR at setup of TestPhones.test_changing_phone_type_hides_then_shows_number_input_field _
[gw1] linux -- Python 3.8.5 /opt/venv/bin/python3.8
request = <SubRequest 'git_data' for <Function test_verify_report_export_does_not_exist>>
    @pytest.fixture(scope="session", autouse=True)
    def git_data(request):
        """
        Append git information into results session
        """
        git_info = dict()
        cmds = (
            ("git_commit_oneline", "git log --oneline  -1 --no-decorate"),
            ("git_commit_sha", "git rev-parse HEAD"),
            ("git_commit_sha_short", "git rev-parse --short HEAD"),
            ("git_branch", "git rev-parse --abbrev-ref HEAD"),
            ("git_repo", "git config --get remote.origin.url"),
        )
        for key, command in cmds:
            try:
                git_info[key] = (
                    subprocess.check_output(command, shell=True, stderr=subprocess.DEVNULL)
                    .decode("utf-8")
                    .strip()
                )
            except subprocess.CalledProcessError:
                pass
        elk = request.config.pluginmanager.get_plugin("elk-reporter-runtime")
>       elk.session_data.update(**git_info)
E       AttributeError: 'NoneType' object has no attribute 'session_data'
../venv/lib/python3.8/site-packages/pytest_elk_reporter.py:470: AttributeError

what i think is happening is this test is running on a worker node which means that in pytest-elk-reporter's pytest_configure hook, the ElkReporter plugin is not being created or registered with the pluginmanager.

if i remove this line:

if not hasattr(config, "slaveinput"):

so that the ElkReporter plugin is created and registered regardless of node, the error goes away. looking at the data from error-free runs i don't see anything that would suggest the data quality suffered.

this leaves me wondering: what behavior is pytest-elk-reporter trying to avoid by only creating and registering the plugin if the test is isn't running on a worker node?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions