pytest-dev / pytest-dev/pytest

`pytest -k` should ignore private attributes (starting with `_`)

Open
#7,539 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I originally opened this issue in hypothesis, but they told me to open it here https://github.com/HypothesisWorks/hypothesis/issues/2508.

When I run pytest -k name, and name only matches hypothesis tests, pytest runs all hypothesis tests, not just the ones that match. When name matches a non-hypothesis test, it only picks the tests that contain name as expected.

I am using pytest 5.4.3 and hypothesis 5.21.0. It happens even when I set aside my pytest.ini and conftest.py.

You can reproduce this at the repo https://github.com/Quansight/ndindex/ by running pytest -v -k repr.

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

Reproduce the behavior in the Quansight/ndindex repository with pytest -v -k repr, using the reported pytest 5.4.3 and Hypothesis 5.21.0 versions if possible. Start from pytest's -k selection behavior and compare matches from Hypothesis tests with non-Hypothesis tests. Done means private attributes no longer cause unrelated Hypothesis tests to run, while ordinary name matching still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.