-
Notifications
You must be signed in to change notification settings - Fork 1.2k
tests/context: drain generator return so pytest doesn't warn #4652
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
base: master
Are you sure you want to change the base?
Conversation
…eturnNotNoneWarning)
Hello @jtraglia please could you help us review this? |
Hey @omegajudith & @bomanaps this does technically fix the issue (by hiding the warnings), but it's not the proper fix. This will break the reference test generation side of things. For example, this works without warnings:
But this will now fail:
![]() |
I believe the correct solution is to change the decorator order so that consensus-specs/tests/core/pyspec/eth2spec/test/altair/light_client/test_data_collection.py Lines 28 to 37 in aae5237
To be clear, this: @with_light_client
+@spec_state_test_with_matching_config
@with_config_overrides(
{
"BLOB_SCHEDULE": sample_blob_schedule(initial_epoch=1, interval=1),
},
emit=False,
)
-@spec_state_test_with_matching_config
@with_presets([MINIMAL], reason="too slow")
def test_light_client_data_collection(spec, state): This will eventually call consensus-specs/tests/core/pyspec/eth2spec/test/context.py Lines 322 to 328 in aae5237
This decorator will handle this situation here: consensus-specs/tests/core/pyspec/eth2spec/test/utils/utils.py Lines 61 to 73 in aae5237
Please review/update all instances of This issue was not as easy and I thought it would be. Sorry about that. |
@jtraglia the yields when not in generation mode are consumed here: https://github.com/ethereum/consensus-specs/blob/master/tests/core/pyspec/eth2spec/test/utils/utils.py#L68-L73 in |
Fixes #4618.
Pytest raised PytestReturnNotNoneWarning when a test returned a generator.
with_phases was returning the inner generator; this drains it and returns
None so pytest sees a proper test function.
Repro before:
pytest -W error -x -vv tests/core/pyspec/eth2spec/test/altair/light_client
After fix:
12 passed, 0 warnings.