pytest-dev / pytest-dev/pytest
Parametrized nodeid not matching with parametrized IDs
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
This is about this issue in pytest-repeat: https://github.com/pytest-dev/pytest-repeat/issues/21
It seems that the bug doesn't come from the plugin: I managed to reproduce with a simple test here.
It affects all pytest versions, at least since 2.8
I wrote a test and a fix attempt here: https://github.com/vbarbaresi/pytest/commit/12769f0d3bda3c53426ba124e89f0072cc0b320b
The issue is the following: with parametrized IDs and parametrized fixtures, one can't run a test using its node ID with a [parameter] argument
I tracked it down to the x.name vs name matching, which is in my example:
test_foo[1-param] vs test_foo[param]
My fix attempt drops everything after [ on both sides. However, we lose the supplied parameter value so it's not satisfying. I don't know where to fix this properly.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the simple parametrized test described in the issue and compare the node-ID matching behavior with the attempted fix in commit 12769f0d3bda3c53426ba124e89f0072cc0b320b. Trace the x.name versus name comparison, then verify that selecting a test by node ID works with parametrized fixtures and IDs while preserving the supplied parameter value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100