You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Replace raise StopIteration with return - adhere to Pep 479 #2160
As per pytest-dev/pluggy#38 and pep 479, it seems that some pluggy hook wrappers implemented in pytest are still using the soon to be deprecated raise StopIteration mechanism to signal early generator termination.
@tgoodlet indeed, the example looks perfectly valid to convert, i may have been overly pessimistic
we should go and try at least, perhaps we can convert everything just fine
Unless I'm missing something (and that's a possibility since I didn't read PEP-479 thoroughly), can we just replace the raise StopIteration by a return?
This patch seems to work fine in Py2.6, 2.7 and 3.5:
diff --git a/_pytest/python.py b/_pytest/python.py
index e46f2f1..2973d43 100644
--- a/_pytest/python.py+++ b/_pytest/python.py@@ -174,7 +174,7 @@ def pytest_pycollect_makeitem(collector, name, obj):
outcome = yield
res = outcome.get_result()
if res is not None:
- raise StopIteration+ return
# nothing was collected elsewhere, let's do it here
if isclass(obj):
if collector.istestclass(obj, name):
The problem is causing test failures in Custodia on Python 3.6. The test turn all deprecation warnings into fatal failures. For Custodia I put a band-aid on the issue and filter out deprecation warnings from '_pytest\..*'.
Activity
RonnyPfannschmidt commentedon Dec 24, 2016
its impossible to fix this as of now due to support for old python versions
goodboy commentedon Dec 25, 2016
@RonnyPfannschmidt I'm not sure that's true?
Supposedly all code can be made backwards compatible even in Py2.6 as per the original generator's Pep 255. Maybe I'm forgetting something though?
RonnyPfannschmidt commentedon Dec 26, 2016
@tgoodlet indeed, the example looks perfectly valid to convert, i may have been overly pessimistic
we should go and try at least, perhaps we can convert everything just fine
nicoddemus commentedon Dec 27, 2016
Unless I'm missing something (and that's a possibility since I didn't read PEP-479 thoroughly), can we just replace the
raise StopIterationby areturn?This patch seems to work fine in Py2.6, 2.7 and 3.5:
goodboy commentedon Dec 28, 2016
@RonnyPfannschmidt Sounds good :)
@nicoddemus Yep you've got it.
You guys want me to make a PR?
nicoddemus commentedon Dec 28, 2016
Please go ahead. 😁 Thanks!
Replace 'raise StopIteration' usages in the code by 'return's in acco…
tiran commentedon Feb 1, 2017
The problem is causing test failures in Custodia on Python 3.6. The test turn all deprecation warnings into fatal failures. For Custodia I put a band-aid on the issue and filter out deprecation warnings from
'_pytest\..*'.latchset/custodia#105 (comment)