-
Notifications
You must be signed in to change notification settings - Fork 40
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
Unnecessary prefix in test ids when fixture_ref
is used in parametrize_plus
#69
Comments
My first attempt to fix it was to wrap fixture_ref in pytest.param with explicit id, but pytest-cases expects values to be tuple, not ParameterSet. In current output there is clearly unneded prefix |
So you issue is that the generated test id name is a bit unfriendly ;) ( Well I agree, but at the same time I have no clue on how to do better here. Here is how I proceed:
@pytest_parametrize_plus("name", [
fixture_ref(book1_name),
'hi',
'ih',
fixture_ref(book2_name),
])
def test_get_or_create_book(name):
... will create a union of 3 fixtures: This union is named uniquely after the test function name and the parameter name. So it is named:
Any ideas are more than welcome ! It is hard to make things simple here :) |
Concerning your suggestions:
|
First case is working, but yes, name is copied incorrectly, i get 'name0' instead of 'alice', i'll open separate issue.
Do they supposed to throw it or can it be fixed? By my understanding, it can, but with my first idea ids will be lost: python-pytest-cases/pytest_cases/main_fixtures.py Lines 1005 to 1008 in b541402
|
Oh, i missed first message, and now i just read it. Wait a minute, i was trying to do this:
And it passed collect stage, but crashed at test stage (same as simple pytest.mark.parametrize, so i assume this is fine, and i should not use tuples with pytest.param inside). |
By 'ParameterSet should be supported in the list of values' you mean this?
Here is actually two issues: incorrect id, and it doesn't work (it passes ParameterSet to test_function), just like pytest, so here is nothing to fix. When using |
Yes I meant Now concerning removing the prefix, I'm on it. |
Yes, you are correct. Thanks! |
fixture_ref
is used in parametrize_plus
@smarie Thank you for pytest-cases, i've managed to get what i wanted, and it looks almost fine, except for fixture names :)
test output
Originally posted by @last-partizan in pytest-dev/pytest#349 (comment)
The text was updated successfully, but these errors were encountered: