pytest-dev / pytest-dev/pytest-xdist

When using xdist, warnings are not associated with tests in the report

Open
#480 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.9k
Forks
287
Avg merge
9h 30m
Merged PRs (30d)
2

Description

Given the example test from the docs:

import warnings

def api_v1():
    warnings.warn(UserWarning("api v1, should use functions from v2"))
    return 1

def test_one():
    assert api_v1() == 1

When this test is run without xdist, the warning report includes the test's node_id:

❯❯❯ pytest
============================= test session starts ==============================
platform linux -- Python 3.6.7, pytest-5.2.1, py-1.8.0, pluggy-0.13.0
rootdir: /tmp/warn
plugins: forked-1.1.1, xdist-1.30.0
collected 1 item

test_warn.py .                                                           [100%]

=============================== warnings summary ===============================
test_warn.py::test_one
  /tmp/warn/test_warn.py:6: UserWarning: api v1, should use functions from v2
    warnings.warn(UserWarning("api v1, should use functions from v2"))

-- Docs: https://docs.pytest.org/en/latest/warnings.html
======================== 1 passed, 1 warnings in 0.01s =========================

Running the same test with xdist, the node ID test_warn.py::test_one disappears:

❯❯❯ pytest
============================= test session starts ==============================
platform linux -- Python 3.6.7, pytest-5.2.1, py-1.8.0, pluggy-0.13.0
rootdir: /tmp/warn
plugins: forked-1.1.1, xdist-1.30.0
collected 1 item

test_warn.py .                                                           [100%]

=============================== warnings summary ===============================
test_warn.py::test_one
  /tmp/warn/test_warn.py:6: UserWarning: api v1, should use functions from v2
    warnings.warn(UserWarning("api v1, should use functions from v2"))

-- Docs: https://docs.pytest.org/en/latest/warnings.html
======================== 1 passed, 1 warnings in 0.01s =========================

This makes it difficult to trace back which test caused which warning in the CI system.

Ubuntu 18.10

Python 3.6.7

apipkg==1.5
atomicwrites==1.3.0
attrs==19.3.0
execnet==1.7.1
importlib-metadata==0.23
more-itertools==7.2.0
packaging==19.2
pkg-resources==0.0.0
pluggy==0.13.0
py==1.8.0
pyparsing==2.4.2
pytest==5.2.1
pytest-forked==1.1.1
pytest-xdist==1.30.0
six==1.12.0
wcwidth==0.1.7
zipp==0.6.0

Contributor guide

No contributing guide indexed for this repository

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

Reproduce the warning example in test_warn.py with pytest both normally and with xdist, comparing the warnings summary. Trace how xdist handles warning reports and test node IDs; done when the xdist report retains test_warn.py::test_one for the warning, with coverage for both execution modes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.