-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parametrized nodeid not matching with parametrized IDs #4142
Comments
@vbarbaresi |
The test is passing but doesn't check that Now that I look at it again, the issue seems fundamentally hard to fix. To sum up: import pytest
@pytest.fixture(autouse=True)
def __bar(request):
return request.param
def pytest_generate_tests(metafunc):
metafunc.parametrize('__bar', [1], indirect=True)
class TestClass(object):
@pytest.fixture(params=['param'])
def foo(self, request):
pass
def test_foo(self, foo):
pass
Note that there is an old TODO in _pytest/main.py saying # TODO: remove parametrized workaround once collection structure contains parametrization
if x.name == name or x.name.split("[")[0] == name: I feel like it has to do with this issue |
Thanks for the update!
I feel your pain, having worked at collection recently. Given there are no tests I'd argue that you are free to clean this up to match your expectations. Surely @RonnyPfannschmidt has a rant in this regard also.. :) I'd say that a WIP-PR is still something good to have, where you could add your summarized example as a failing test to start from. Use |
@blueyed i actually have a fix on the horizon, but it will at least need 3-4 major releases to sort nodes out - given that outline no more ranting needed |
@RonnyPfannschmidt I'd be interested in the fix, if it's available? |
The node refactoring needed is still in very early stages |
Not sure if it helps but here is the work around I used to change the generated pytest id's when the parameter contained characters like "::" and "\n" I need to change the Id so that both Visual Studio's Test Explorer could parse it correctly and pytest was having issues running a single test when trying to call it using the ID |
Any progress on this? |
The node refactoring has been progressing, but I don't think there's news about this issue in particular (@RonnyPfannschmidt might give more details here). |
nothing new there, after the rest of the |
This is about this issue in pytest-repeat: pytest-dev/pytest-repeat#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: vbarbaresi@12769f0
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
vsname
matching, which is in my example:test_foo[1-param]
vstest_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.The text was updated successfully, but these errors were encountered: