Skip to content

The attachments are not in the Nunit report when using pytest-xdist #80

@anastasia-vlasova-gmg

Description

@anastasia-vlasova-gmg

The environment:

  • pytest=8.2.2
  • pytest-nunit=1.0.7
  • pytest-xdist=3.6.1
  • python=3.10.8

The script:

import pytest

@pytest.mark.parametrize("params", [(1, 1),(2, 1)])
def test_temp(params, add_nunit_attachment):

    p = f"{str(params[0])}.txt"
    with open(p, "tw") as f:
        f.write("")
    add_nunit_attachment(p, p)
    assert params[0] == params[1]

The script when run without arguments produces test-output.xml containing:

<attachments>
  <attachment>
    <filePath>1.txt</filePath>
    <description>1.txt</description>
  </attachment>
</attachments>

as expected.

When run with -n 2 (2 xdist workers) produces test-output.xml with no attachments.

I don't see this behavior mentioned in the known limitations at the moment.
We use pytest-azurepipelines to run tests in CI and publishing attachments of the failing tests resulting files is a very useful instrument of the test failure diagnostics.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions