-
-
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
Replace raise StopIteration with return - adhere to Pep 479 #2160
Comments
its impossible to fix this as of now due to support for old python versions |
@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? |
@tgoodlet indeed, the example looks perfectly valid to convert, i may have been overly pessimistic |
Unless I'm missing something (and that's a possibility since I didn't read PEP-479 thoroughly), can we just replace the 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): |
@RonnyPfannschmidt Sounds good :) You guys want me to make a PR? |
Please go ahead. 😁 Thanks! |
…rdance to PEP-479 Fix pytest-dev#2160
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 |
As per pytest-dev/pluggy#38 and pep 479, it seems that some
pluggy
hook wrappers implemented inpytest
are still using the soon to be deprecatedraise StopIteration
mechanism to signal early generator termination.An example would be
pytest_pycollect_makeitem
.As indicated in the pep all such usage should be changed to simple
return
s in Py3.6+.The text was updated successfully, but these errors were encountered: