Skip to content

Conversation

@Iwithyou2025
Copy link
Contributor

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.

@RonnyPfannschmidt RonnyPfannschmidt added type: enhancement new feature or API change, should be merged into features branch type: docs documentation improvement, missing or needing clarification bot:chronographer:provided (automation) changelog entry is part of PR labels Jun 17, 2025
Copy link
Member

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

Well merge after we sort the twisted issue

@nicoddemus nicoddemus force-pushed the docs-clarify-addopts-comma branch from e3a012b to 711ed23 Compare June 17, 2025 20:47
@nicoddemus nicoddemus added skip news used on prs to opt out of the changelog requirement backport 8.4.x labels Jun 17, 2025
@nicoddemus nicoddemus enabled auto-merge (squash) June 17, 2025 20:48
@nicoddemus nicoddemus disabled auto-merge June 17, 2025 20:48
@nicoddemus nicoddemus enabled auto-merge (squash) June 17, 2025 20:49
@nicoddemus nicoddemus merged commit 40a1713 into pytest-dev:main Jun 17, 2025
36 checks passed
@patchback
Copy link

patchback bot commented Jun 17, 2025

Backport to 8.4.x: 💚 backport PR created

✅ Backport PR branch: patchback/backports/8.4.x/40a1713d42187732d0095dd1623b1424fb2bc489/pr-13529

Backported as #13532

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR skip news used on prs to opt out of the changelog requirement type: docs documentation improvement, missing or needing clarification type: enhancement new feature or API change, should be merged into features branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants