pytest-dev / pytest-dev/pytest

add_marker with usefixtures no longer works with pytest 8.0.0

Open
#11,873 7 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

type: regression
Dominant language
Python
Stars
14.5k
Forks
3.4k
Avg merge
2d 9h
Merged PRs (30d)
35

Description

I believe this may be related to https://github.com/pytest-dev/pytest/issues/3664.

In pandas, we dynamically add a marker for our doctests so that we don't need import pandas as pd and import numpy as np in every docstring.

https://github.com/pandas-dev/pandas/blob/9008ee5810c09bc907b5fdc36fc3c1dff4a50c55/pandas/conftest.py#L191-L198

The add_doctest_imports fixture is here.

https://github.com/pandas-dev/pandas/blob/9008ee5810c09bc907b5fdc36fc3c1dff4a50c55/pandas/conftest.py#L253-L259

With pytest 8.0.0, add_marker no longer has any effect. Is the intentional, and if so, is there an alternative?

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 reading the linked pandas/conftest.py sections around lines 191-198 and 253-259, especially the add_doctest_imports fixture, then reproduce the behavior with pytest 8.0.0. Compare how add_marker is applied before and after that release; done means restoring the doctest marker behavior or documenting a verified alternative.

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.