Skip to content

ignore_collect hook in conftest returning False causes infinite recursion #3825

@Sup3rGeo

Description

@Sup3rGeo
  • Minimal example if possible

I have a project with the following layout:

image

All __init__ files are blank, except the internal conftest.py file with has the contents shown in the image.

Running it causes the following traceback:

(venv-clean-py) D:\WORK\pytest-collection-conftest-bug>pytest test
============================= test session starts =============================
platform win32 -- Python 3.6.3, pytest-3.7.1, py-1.5.4, pluggy-0.7.1
rootdir: D:\WORK\pytest-collection-conftest-bug, inifile:
collected 0 items / 1 errors                                                   

=================================== ERRORS ====================================
________ ERROR collecting test/integrations/rerunfailures/__init__.py _________
venv-clean-py\lib\site-packages\pluggy\hooks.py:258: in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
venv-clean-py\lib\site-packages\pluggy\manager.py:67: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
venv-clean-py\lib\site-packages\pluggy\manager.py:61: in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
venv-clean-py\lib\site-packages\_pytest\python.py:210: in pytest_collect_file
    return ihook.pytest_pycollect_makemodule(path=path, parent=parent)
venv-clean-py\lib\site-packages\pluggy\hooks.py:258: in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
venv-clean-py\lib\site-packages\pluggy\manager.py:67: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
venv-clean-py\lib\site-packages\pluggy\manager.py:61: in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
venv-clean-py\lib\site-packages\_pytest\python.py:215: in pytest_pycollect_makemodule
    return Package(path, parent)
venv-clean-py\lib\site-packages\_pytest\python.py:552: in __init__
    self, fspath, parent=parent, config=config, session=session, nodeid=nodeid
venv-clean-py\lib\site-packages\_pytest\nodes.py:351: in __init__
    fspath = py.path.local(fspath)  # xxx only for test_resultlog.py?
venv-clean-py\lib\site-packages\py\_path\local.py:158: in __init__
    self.strpath = abspath(path)
C:\Python36\lib\ntpath.py:551: in abspath
    return normpath(path)
C:\Python36\lib\ntpath.py:493: in normpath
    prefix, path = splitdrive(path)
C:\Python36\lib\ntpath.py:141: in splitdrive
    if len(p) >= 2:
E   RecursionError: maximum recursion depth exceeded in comparison
!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!
=========================== 1 error in 2.44 seconds ===========================

Checking the pytest debug output (--debug), I see that this section gets repeated a billion times:

    genitems <Package 'D:\\WORK\\allure-python\\allure-pytest\\test\\integrations\\rerunfailures'> [collection]
      pytest_collectstart [hook]
          collector: <Package 'D:\\WORK\\allure-python\\allure-pytest\\test\\integrations\\rerunfailures'>
      finish pytest_collectstart --> [] [hook]
      pytest_make_collect_report [hook]
          collector: <Package 'D:\\WORK\\allure-python\\allure-pytest\\test\\integrations\\rerunfailures'>
        pytest_ignore_collect [hook]
            path: D:\WORK\allure-python\allure-pytest\test\integrations\rerunfailures\__pycache__
            config: <_pytest.config.Config object at 0x000002162E356DA0>
        finish pytest_ignore_collect --> False [hook]
        pytest_collect_directory [hook]
            path: D:\WORK\allure-python\allure-pytest\test\integrations\rerunfailures\__pycache__
            parent: <Package 'D:\\WORK\\allure-python\\allure-pytest\\test\\integrations\\rerunfailures'>
        finish pytest_collect_directory --> None [hook]
        pytest_ignore_collect [hook]
            path: D:\WORK\allure-python\allure-pytest\test\integrations\rerunfailures\__init__.py
            config: <_pytest.config.Config object at 0x000002162E356DA0>
        finish pytest_ignore_collect --> False [hook]
        pytest_collect_file [hook]
            path: D:\WORK\allure-python\allure-pytest\test\integrations\rerunfailures\__init__.py
            parent: <Package 'D:\\WORK\\allure-python\\allure-pytest\\test\\integrations\\rerunfailures'>
          pytest_pycollect_makemodule [hook]
              path: D:\WORK\allure-python\allure-pytest\test\integrations\rerunfailures\__init__.py
              parent: <Package 'D:\\WORK\\allure-python\\allure-pytest\\test\\integrations\\rerunfailures'>
          finish pytest_pycollect_makemodule --> <Package 'D:\\WORK\\allure-python\\allure-pytest\\test\\integrations\\rerunfailures'> [hook]
        finish pytest_collect_file --> [<DoctestModule '__init__.py'>, <Package 'D:\\WORK\\allure-python\\allure-pytest\\test\\integrations\\rerunfailures'>] [hook]
      finish pytest_make_collect_report --> <CollectReport 'test/integrations/rerunfailures/__init__.py' lenresult=2 outcome='passed'> [hook]
    genitems <DoctestModule '__init__.py'> [collection]
      pytest_collectstart [hook]
          collector: <DoctestModule '__init__.py'>
      finish pytest_collectstart --> [] [hook]
      pytest_make_collect_report [hook]
          collector: <DoctestModule '__init__.py'>
      finish pytest_make_collect_report --> <CollectReport 'test/integrations/rerunfailures/__init__.py' lenresult=0 outcome='passed'> [hook]
      pytest_collectreport [hook]
          report: <CollectReport 'test/integrations/rerunfailures/__init__.py' lenresult=0 outcome='passed'>
      find_module called for: termios [assertion]
      finish pytest_collectreport --> [] [hook]
  • pip list of the virtual environment you are using
atomicwrites (1.1.5)
attrs (18.1.0)
colorama (0.3.9)
more-itertools (4.3.0)
pip (9.0.1)
pluggy (0.7.1)
py (1.5.4)
pytest (3.7.1)
setuptools (28.8.0)
six (1.11.0)
  • pytest and operating system versions
  • pytest (3.7.1)
  • windows 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions