Fix data_consumer generator exhaustion when decorators are stacked - #6
Merged
Conversation
paveldedik
commented
May 7, 2026
| """ | ||
|
|
||
| output_name = data_provider_kwargs.pop('_output_name', None) | ||
| if isinstance(callable_or_property_or_str, types.GeneratorType): |
Member
Author
There was a problem hiding this comment.
Before the fix, this is how it behaved:
@data_consumer([True, False], _output_name='flag')
@data_consumer((x for x in [1, 2, 3]), _output_name='number')
def test_something(self, number, flag):
print(number, flag)It would print:
1 True
2 True
3 True
The workaround would be using a list comprehension instead of a generator:
@data_consumer([x for x in [1, 2, 3]], _output_name='number')Anyway, after this fix, it works just fine:
1 True
2 True
3 True
1 False
2 False
3 False
A generator expression passed to @data_consumer is a one-shot iterator. When stacked decorators create an outer loop, the inner generator was fully consumed on the first pass and silently yielded nothing on subsequent passes, dropping test combinations without any error. Fix: materialize generator arguments into lists at decoration time so they can be re-iterated for each outer-loop pass.
paveldedik
force-pushed
the
pd/fix-data-consumer-generator
branch
from
May 7, 2026 13:55
e293cd5 to
b95595d
Compare
xkubov
approved these changes
May 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A generator expression passed to @data_consumer is a one-shot iterator. When stacked decorators create an outer loop, the inner generator was fully consumed on the first pass and silently yielded nothing on subsequent passes, dropping test combinations without any error.
Fix: materialize generator arguments into lists at decoration time so they can be re-iterated for each outer-loop pass.