Skip to content

[PR #13529/40a1713d backport][8.4.x] docs: clarify comma-separated -p NAME,NAME2 limitations and recommend stable alternatives #13532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

patchback[bot]
Copy link

@patchback patchback bot commented Jun 17, 2025

This is a backport of PR #13529 as merged into main (40a1713).

Issue Body

Description
In the “Disabling plugins from autoloading” section, the docs show:

[pytest]
addopts = --disable-plugin-autoload -p NAME,NAME2

However, in practice this often fails with:

ImportError: Error importing plugin "testmon,sugar,xdist": No module named 'testmon,sugar,xdist'

This happens both when that line is placed in pytest.ini (due to ConfigParser + shlex.split behavior) and in Windows CMD/PowerShell (shell does not preserve the comma list as a single argument). Pytest ends up trying to import the entire comma-separated string as one module.


Steps to Reproduce

  1. Install pytest ≥8.4 and plugins pytest-sugar, pytest-xdist.

  2. Create pytest.ini containing:

    [pytest]
    addopts = --disable-plugin-autoload -p sugar,xdist
  3. Run in Windows CMD or PowerShell:

    pytest
  4. Observe the ImportError.


Actual Behavior

ImportError: Error importing plugin "sugar,xdist": No module named 'testmon,sugar,xdist'

Expected Behavior
The doc’s example should note that a single -p NAME,NAME2 is not reliably split into two plugin names when used in pytest.ini or on Windows shells. Users need the following stable patterns:


Suggested Documentation Update

[pytest]
addopts =
    --disable-plugin-autoload
    -p NAME
    -p NAME2

Environment

  • pytest version: e.g. 8.4.0
  • OS: Windows 10/11 CMD & PowerShell
  • Plugins installed: pytest-sugar, pytest-xdist

By calling out these parsing pitfalls and offering clear alternatives, the docs will better match real-world behavior and save users from this confusing import error.

@nicoddemus nicoddemus force-pushed the patchback/backports/8.4.x/40a1713d42187732d0095dd1623b1424fb2bc489/pr-13529 branch from 7949b89 to 9d19ed9 Compare June 17, 2025 21:12
@nicoddemus nicoddemus enabled auto-merge (squash) June 17, 2025 21:12
@nicoddemus nicoddemus merged commit 5dc5880 into 8.4.x Jun 17, 2025
36 checks passed
@nicoddemus nicoddemus deleted the patchback/backports/8.4.x/40a1713d42187732d0095dd1623b1424fb2bc489/pr-13529 branch June 17, 2025 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants