-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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: ids: support generator/iterator #6174
Conversation
Fails on py35 only due to random order (easy to fix / ignore, but IIRC there was an issue for that already maybe?):
(https://travis-ci.org/pytest-dev/pytest/jobs/611099976#L6281) |
For reference I'm planning to add |
b0d3ba6
to
7e59308
Compare
10179ce
to
167d5fb
Compare
src/_pytest/python.py
Outdated
else: | ||
assert "ids" in kwargs | ||
kwargs = kwargs.copy() | ||
kwargs["ids"] = ids |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having ids either as arg or kwarg is also not nice here.
Could be combined with _has_param_ids
though at least.
src/_pytest/python.py
Outdated
@@ -1016,6 +1042,7 @@ def parametrize(self, argnames, argvalues, indirect=False, ids=None, scope=None) | |||
) | |||
newcalls.append(newcallspec) | |||
self._calls = newcalls | |||
return ids |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not happy about having to return this here (for storing it in pytest_generate_tests
then).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solving the wrong problem at the wrong place feels like that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main problem here is passing args
and kwargs
, but not the mark.
This could be done instead here also - but the function can be used by itself also (without a mark), so I wanted to keep it apart. But having an optional store_resolved_ids_on_mark
kwarg might suffice then.
Returning the generated ids is not too bad also after all, but I've felt that it might be limiting in the future, and should therefore return the generated calls also etc.
@@ -153,8 +161,19 @@ def combined_with(self, other): | |||
combines by appending args and merging the mappings | |||
""" | |||
assert self.name == other.name | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we might want to add a comment that this is intended to be a temporary hack to be resolved with object based marks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Will revisit before merging.
Thanks for the approval - I'm glad we could figure out something in the end.
Fixes pytest-dev#759 - Adjust test_parametrized_ids_invalid_type, create list to convert tuples Ref: pytest-dev#1857 (comment) - Changelog for int to str conversion Ref: pytest-dev#1857 (comment)
Fixes #759
Via blueyed#105.