Skip to content

StopIteration error in CircleCI using split tests pattern #4344

@Morendil

Description

@Morendil

These lines in release 3.10.0:

pytest/src/_pytest/main.py

Lines 550 to 551 in 5ac4eff

if argpath.basename == "__init__.py":
yield next(m[0].collect())

…are causing a regression when running tests under CircleCI (with the Python 3.7 image) with the recommended split test pattern and globbing:

pytest `circleci tests glob "tests/**/*.py" | circleci tests split`

(We are not seeing the same failure in Python 2 builds.)

A minimal reproduction consists simply of:

touch __init__.py
pytest __init__.py

============================================================================================================ test session starts =============================================================================================================
platform linux -- Python 3.7.0, pytest-3.10.0, py-1.7.0, pluggy-0.8.0
rootdir: /app, inifile: setup.cfg
collected 0 items / 1 errors

=================================================================================================================== ERRORS ===================================================================================================================
_____________________________________________________________________________________________________________ ERROR collecting  ______________________________________________________________________________________________________________
/usr/local/lib/python3.7/site-packages/_pytest/main.py:568: in _collect
    yield next(m[0].collect())
E   StopIteration

The above exception was the direct cause of the following exception:
/usr/local/lib/python3.7/site-packages/_pytest/runner.py:212: in __init__
    self.result = func()
/usr/local/lib/python3.7/site-packages/_pytest/runner.py:272: in <lambda>
    call = CallInfo(lambda: list(collector.collect()), "collect")
/usr/local/lib/python3.7/site-packages/_pytest/main.py:478: in collect
    for x in self._collect(arg):
E   RuntimeError: generator raised StopIteration
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
========================================================================================================== 1 error in 0.30 seconds ===========================================================================================================

Our pip list is simply a fresh install of PyTest:

Package        Version
-------------- -------
atomicwrites   1.2.1
attrs          18.2.0
more-itertools 4.3.0
pip            18.0
pluggy         0.8.0
py             1.7.0
pytest         3.10.0
setuptools     40.0.0
six            1.11.0
wheel          0.31.1
  • Include a detailed description of the bug or suggestion
  • pip list of the virtual environment you are using
  • pytest and operating system versions
  • Minimal example if possible

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: collectionrelated to the collection phasetype: bugproblem that needs to be addressedtype: regressionindicates a problem that was introduced in a release which was working previously

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions