GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||
GeezerVison is showing github.com — use Contextmanagers to handle StopIteration in generators by RonnyPfannschmidt · Pull Request #12934 · pytest-dev/pytest Conversation
Member
yield from is a generator boundary that transfers StopIteration into a RuntimeError closes #12929
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Tusenka
approved these changes
|
There was an error while loading. Please reload this page.
|
src/_pytest/threadexception.py and src/_pytest/unraisableexception.py both use regular trylast hooks instead of generators, so the conflicts can be resolved by checking them out from main |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
this won't pass without a new Pluggy release |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@RonnyPfannschmidt what is the status here? Do you plan to make a |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Indeed I intend to give this priority by the end of the month |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
as it turns out, StopIteration is not transparent on the boundaries of generators # Conflicts: # src/_pytest/threadexception.py # src/_pytest/unraisableexception.py
69e78b7 to
4f9cf8d
Compare
f92fb28 to
c69bb2a
Compare
|
@RonnyPfannschmidt I wrote some test cases for this, I hope you find them useful: def test_stop_iteration_from_collect(pytester: Pytester) -> None: pytester.makepyfile(test_it="raise StopIteration('hello')") result = pytester.runpytest() assert result.ret == ExitCode.INTERRUPTED result.assert_outcomes(failed=0, passed=0, errors=1) result.stdout.fnmatch_lines( [ "=========================== short test summary info ============================", "ERROR test_it.py - StopIteration: hello", "!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!", "=============================== 1 error in * ===============================", ] ) def test_stop_iteration_runtest_protocol(pytester: Pytester) -> None: pytester.makepyfile( test_it=""" import pytest @pytest.fixture def fail_setup(): raise StopIteration(1) def test_fail_setup(fail_setup): pass def test_fail_teardown(request): def stop_iteration(): raise StopIteration(2) request.addfinalizer(stop_iteration) def test_fail_call(): raise StopIteration(3) """ ) result = pytester.runpytest() assert result.ret == ExitCode.TESTS_FAILED result.assert_outcomes(failed=1, passed=1, errors=2) result.stdout.fnmatch_lines( [ "=========================== short test summary info ============================", "FAILED test_it.py::test_fail_call - StopIteration: 3", "ERROR test_it.py::test_fail_setup - StopIteration: 1", "ERROR test_it.py::test_fail_teardown - StopIteration: 2", "==================== 1 failed, 1 passed, 2 errors in * =====================", ] ) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
note this is still currently blocked by a release of pytest-dev/pluggy#545 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
i intend to land pytest-dev/pluggy#546 as before the next release of pluggy |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
im ok with squashing |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
tests raising StopIteration break pytest/pluggy
There was an error while loading. Please reload this page.