pytest-dev / pytest-dev/pytest

Fixture record_testsuite_property does not work with pytest-xdist

Open
#7,767 15 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

plugin: junitxml plugin: xdist topic: fixtures
Dominant language
Python
Stars
14.5k
Forks
3.4k
Avg merge
2d 9h
Merged PRs (30d)
35

Description

According to the docs it is possible to add a junit property at test suite level. This will work fine without pytest-xdist but fails when adding -n2 or similiar to pytest args.

Error description
The test suite properties ARCH, STORAGE_TYPE shown below are not contained in the junit.xml when running pytest-xdist.

Note
I read through the existing test code which does not execute pytest-xdist. Is it wanted to call pytest-xdist in this repository?

How to reproduce

# conftest.py
import pytest

@pytest.fixture(scope="session", autouse=True)
def log_global_env_facts(record_testsuite_property):
    record_testsuite_property("ARCH", "PPC")
    record_testsuite_property("STORAGE_TYPE", "CEPH")
# test_me.py
class TestMe:
    def test_foo(self):
        assert True
(venv) pip list
Package        Version
-------------- -------
apipkg         1.5
atomicwrites   1.4.0
attrs          20.2.0
colorama       0.4.3
execnet        1.7.1
iniconfig      1.0.1
more-itertools 8.5.0
packaging      20.4
pip            20.2.3
pluggy         0.13.1
py             1.9.0
pyparsing      2.4.7
pytest         6.0.2
pytest-forked  1.3.0
pytest-xdist   2.1.0
setuptools     50.3.0
six            1.15.0
toml           0.10.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the shown conftest.py and test_me.py fixtures and pytest-xdist using -n2, then inspect the record_testsuite_property implementation and the JUnit XML output path. Done means ARCH and STORAGE_TYPE appear in junit.xml when the tests run under pytest-xdist, with coverage added for the parallel case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.