pytest-dev / pytest-dev/pytest

Pytest doen't rewrite conftest plugins

Open
#13,517 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

As per discussed:

I try to run pytest rewriting for custom plugins. However it doesn't load a conftest plugin at the rewrting stage.

Example:

https://github.com/Tusenka/pytest/tree/disable_assertion_rewriting_external_modules/testing/example_scripts/rewrite

Expected result:

It sees the conftest plugin "some_plugin "for rewritng.

Result:

It doesn't see conftest plugins:
image
Result of provided plugins:
['pytest', 'zope.interface', 'idna', 'anyio', 'sniffio', 'filelock', 'cachetools', 'incremental', 'greenlet', 'pluggy', 'hypothesis', 'Automat', 'wheel', 'virtualenv', 'coverage', 'pip', 'distlib', 'mock', 'pre_commit', 'typing_extensions', 'elementpath', 'pytest-twisted', 'PyYAML', 'pyproject-api', 'identify', 'colorama', 'urllib3', 'hyperlink', 'Pygments', 'sortedcontainers', 'constantly', 'nodeenv', 'xmlschema', 'setuptools', 'attrs', 'requests', 'pytest', 'exceptiongroup', 'decorator', 'platformdirs', 'packaging', 'charset-normalizer', 'cfgv', 'Twisted', 'certifi', 'chardet', 'tox', 'argcomplete', 'iniconfig', 'jaraco.collections', 'zipp', 'typeguard', 'wheel', 'importlib_metadata', 'jaraco.text', 'jaraco.context', 'autocommand', 'tomli', 'typing_extensions', 'more-itertools', 'jaraco.functools', 'packaging', 'platformdirs', 'inflect', 'backports.tarfile']

`https://github.com/pytest-dev/pytest/blob/9e9633de9da7a9fab03b4bba3a326bf85b412050/src/_pytest/config/__init__.py#L1293

Pip info:

anyio 4.9.0
argcomplete 3.6.2
attrs 25.3.0
Automat 25.4.16
cachetools 5.5.2
certifi 2025.4.26
cfgv 3.4.0
chardet 5.2.0
charset-normalizer 3.4.2
colorama 0.4.6
constantly 23.10.4
coverage 7.8.0
decorator 5.2.1
distlib 0.3.9
elementpath 5.0.0
exceptiongroup 1.3.0
filelock 3.18.0
greenlet 3.2.2
hyperlink 21.0.0
hypothesis 6.131.9
identify 2.6.12
idna 3.10
incremental 24.7.2
iniconfig 2.1.0
mock 5.2.0
nodeenv 1.9.1
packaging 25.0
pip 25.0.1
platformdirs 4.3.8
pluggy 1.5.0
pre_commit 4.2.0
Pygments 2.19.1
pyproject-api 1.9.1
pytest 8.5.0.dev32+g1d5a61269.d20250613 /home/cas12/PycharmProjects/pytest-play
pytest-twisted 1.14.3
PyYAML 6.0.2
requests 2.32.3
setuptools 78.1.0
sniffio 1.3.1
sortedcontainers 2.4.0
tox 4.26.0
Twisted 24.11.0
typing_extensions 4.13.2
urllib3 2.4.0
virtualenv 20.31.2
wheel 0.45.1
xmlschema 4.0.1
zope.interface 7.2

Pytest and OS:

Image

  • a detailed description of the bug or problem you are having
  • output of pip list from the virtual environment you are using
  • pytest and operating system versions
  • minimal example if possible

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 with the provided reproduction under testing/example_scripts/rewrite and inspect src/_pytest/config/init.py around line 1293. Trace how assertion rewriting discovers plugins and compare the observed list with the expected conftest plugin. Done means the reproduction detects and rewrites the conftest plugin without regressing existing plugin handling.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.