diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 006c0ed0f3d..612ee0f3b38 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,14 +1,21 @@ 3.0.7 (unreleased) -======================= +================== * +* Replace ``raise StopIteration`` usages in the code by simple ``returns`` to finish generators, in accordance to `PEP-479`_ (`#2160`_). + Thanks `@tgoodlet`_ for the report and `@nicoddemus`_ for the PR. + * * * +.. _#2160: https://github.com/pytest-dev/pytest/issues/2160 + +.. _PEP-479: https://www.python.org/dev/peps/pep-0479/ + 3.0.6 (2017-01-22) ================== diff --git a/_pytest/python.py b/_pytest/python.py index e46f2f1bcfb..2973d43d699 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):