You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pytest tests/test_database.py::TestDatabaseFixtures::test_access\[db\] works, but adding --count 10 fails:
collecting 0 items
ERROR: not found: …/Vcs/pytest-django/tests/test_database.py::TestDatabaseFixtures::test_access[db]
(no name '…/Vcs/pytest-django/tests/test_database.py::TestDatabaseFixtures::test_access[db]' in any of [<Instance '()'>])
It happens in older pytest versions as well (at least until 2.8)
I opened an issue on pytest tracker pytest-dev/pytest#4142 providing a unit test reproducing the bug.
This is happening for me with pytest 7.1.0 and pytest-repeat 0.9.1.
Is it related to the way test items are renamed and collected, in that pytest-repeat modifies the name with extra parameters, and this affects name matching?
For example, with a parametrized test that has one parameter of value 256, this works (runs once):
$ pytest test.py::test_something[256]
And this works (runs 1000 times but for each parameter, which may be far too many tests):
$ pytest test.py::test_something --count 1000
But to run for a single parameter value, this does not work:
$ pytest test.py::test_something[256] --count 1000
(no name 'test.py::test_something[256]' in any of [<Module test.py>])
We also cannot select individual counts using nodeid:
(pytest-repeat) $ pytest 'test_param.py::test_foo[10-2-3]'
=========================== test session starts ============================
collected 0 items
========================== no tests ran in 0.00s ===========================
ERROR: not found: /Users/okken/projects/pytest-repeat/test_param.py::test_foo[10-2-3]
(no name '/Users/okken/projects/pytest-repeat/test_param.py::test_foo[10-2-3]' in any of [<Module test_param.py>])
I don't think this is a bug, it's an affect of when the counts are added to the nodeid.
I personally wouldn't know how to describe the feature request. Partly because I don't fully understand the limitations of pytest that are the problem. But I agree.
I do think, at the very least, this issue should remain open until the workaround is documented and easy to find.
Activity
RonnyPfannschmidt commentedon Jul 3, 2018
does this happen in older pytest versions ?
Fix pytest-dev#21: allow using repeat(1) marker to disable repeat
vbarbaresi commentedon Oct 14, 2018
It happens in older pytest versions as well (at least until 2.8)
I opened an issue on pytest tracker pytest-dev/pytest#4142 providing a unit test reproducing the bug.
blueyed commentedon Oct 14, 2018
blueyed commentedon Oct 14, 2018
1Mark commentedon Jul 17, 2021
Any progress on this?
vyahello commentedon Aug 17, 2021
Hey, looks like this happens on the latest pytest version
Do we have any updates on this one?
DavidAntliff commentedon Feb 20, 2023
This is happening for me with pytest 7.1.0 and pytest-repeat 0.9.1.
Is it related to the way test items are renamed and collected, in that
pytest-repeatmodifies the name with extra parameters, and this affects name matching?For example, with a parametrized test that has one parameter of value
256, this works (runs once):And this works (runs 1000 times but for each parameter, which may be far too many tests):
But to run for a single parameter value, this does not work:
And this runs once, but does not repeat:
Is there a known workaround, aside from running
pytestover and over in a shell script loop?DavidAntliff commentedon Aug 1, 2023
I'm curious if there's been any thinking from the contributors as to how this might work, if we could get it to work?
I come across this so often I'd be happy to help fix it, if I could get in sync with the designers' thoughts...
RonnyPfannschmidt commentedon Aug 1, 2023
Currently no design work on this was done
I believe major internals Changes in pytest itself are necessary to enable this
okken commentedon Oct 5, 2023
Seems to work fine now, with pytest 7.4.2 and pytest-repeat 0.9.2
test run:
DavidAntliff commentedon Oct 5, 2023
@okken I think the issue remains and it’s that you can’t do this:
RonnyPfannschmidt commentedon Oct 5, 2023
This one is unfixable without a major change in pytest
okken commentedon Oct 5, 2023
The act of using
--count 3changes the nodeids, so with--count 3,test_foo[10]no longer exists.There is a workaround, selecting parameters by keyword instead of nodeid:
okken commentedon Oct 5, 2023
We also cannot select individual counts using nodeid:
I don't think this is a bug, it's an affect of when the counts are added to the nodeid.
And there is the same workaround, use keywords.
okken commentedon Oct 5, 2023
@RonnyPfannschmidt this brings me to a question of "why leave this issue open?"
pytest-repeatand more importantly,pytest.pytestchanges, it's not fixable.So why keep this open?
okken commentedon Oct 5, 2023
Also just swapped "bug" for "enhancement", because there is a way to do the requested action, just not with the desired syntax.
RonnyPfannschmidt commentedon Oct 5, 2023
I'd like to turn this into a feature request for pytest
okken commentedon Oct 5, 2023
I personally wouldn't know how to describe the feature request. Partly because I don't fully understand the limitations of pytest that are the problem. But I agree.
I do think, at the very least, this issue should remain open until the workaround is documented and easy to find.
okken commentedon Oct 5, 2023
@DavidAntliff Does the
-kworkaround work for your use case?DavidAntliff commentedon Oct 6, 2023
Yes, that works for me - thank you. I've been looking for a way to do this for a while.