pytest-dev / pytest-dev/pytest

session.testscollected misnomer

Open
#9,614 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

pytest version: 7.0.0

In hookspec.py

 5. Set ``session.testscollected`` to the number of collected items

But this variable actually contains the number of SELECTED tests.
The value is set at after pytest_collection_modifyitems, where items might be deselected.

To avoid breaking existing code I would suggest just deprecating this variable and adding:

  • tests_selected
  • tests_collected

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 in hookspec.py and trace where session.testscollected is assigned after pytest_collection_modifyitems, including the effect of deselected items. Review the existing session attribute API and compatibility requirements. Done means the selected and collected counts have clear, distinct names without breaking existing users.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.