Skip to content

Collection "not found" error drops the requested [params] parametrization #15422

Closed as not planned

Description

@0718lol
  • a detailed description of the bug or problem you are having
  • output of pip list / version details from the environment
  • pytest and operating system versions
  • minimal example

Description

When selecting a non-existent parametrized test ID on the command line (e.g. pytest "test_x.py::test_x[missing]"), pytest's ERROR: not found: diagnostic silently drops the [missing] parametrization suffix and reports only test_x.py::test_x.

This is misleading because test_x does exist—only the requested [missing] parameter variant does not.

Minimal Example

# test_x.py
import pytest


@pytest.mark.parametrize("a", [pytest.param(1, id="one")])
def test_x(a):
    assert a

Run:

$ pytest "test_x.py::test_x[missing]"

Actual output:

ERROR: not found: /path/to/test_x.py::test_x
(no match in any of [<Module test_x.py>])

Expected output:

ERROR: not found: /path/to/test_x.py::test_x[missing]
(no match in any of [<Module test_x.py>])

Root Cause & Suggested Fix

In src/_pytest/main.py (Session.perform_collect, line 1045):

if not any_matched_in_initial_part:
    report_arg = "::".join((str(argpath), *names))
    if parametrization is not None:
        report_arg += parametrization
    self._notfound.append((report_arg, notfound_collectors))

Lines 1027–1029 use parametrization during matching (node.name == matchparts[0] + parametrization), but line 1045 omits it when building report_arg for self._notfound.

Environment

  • pytest: 10.0.0.dev60+g9efd0121a (main@9efd0121a, also reproducible on pytest 9.x)
  • Python: 3.12 / 3.14
  • OS: macOS (Darwin arm64)

Happy to open a PR with a pytester regression test in testing/acceptance_test.py if this looks good.

Activity

  1. RonnyPfannschmidt commented on Nov 21, 2026

    @RonnyPfannschmidt
    Member

    🤖 Written by Claude Opus 5.5 via Claude Code for the pytest maintainers; I prompted it, it did the work, I read it.

    Closing as AI farming. This issue is one of 18 agent-generated reports this account filed today, two or three per minute across nine unrelated repositories, each with a ready-made fix and an offer to open a PR. It carries no AI disclosure, which our policy requires. Within 16 minutes another account turned it into #15423, which is how this pattern feeds drive-by PRs.

    Our AI policy: https://github.com/pytest-dev/pytest/blob/main/CONTRIBUTING.rst


    Generated by Claude Code

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions