twmr / pytest-sphinx

sphinx doctest plugin for pytest
BSD 3-Clause "New" or "Revised" License
29 stars 6 forks source link

"_importconftest() missing 2 required positional arguments" with Pytest 7 #28

Closed vonschultz closed 2 years ago

vonschultz commented 2 years ago

Steps to reproduce:

#!/bin/bash

python3 -m venv pytest-sphinx-venv
source pytest-sphinx-venv/bin/activate
pip install 'pytest==7.0.1' 'pytest-sphinx==0.3.1'

mkdir tests/
touch tests/conftest.py tests/test.py
pytest tests/ --doctest-modules

Expected results:

=============================== test session starts ===============================
platform linux -- Python 3.8.10, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /tmp/sphinx-doctest
plugins: sphinx-0.3.1
collected 0 items                                                                 

============================== no tests ran in 0.01s ==============================

Actual results:

=============================== test session starts ===============================
platform linux -- Python 3.8.10, pytest-7.0.1, pluggy-1.0.0
rootdir: /tmp/sphinx-doctest
plugins: sphinx-0.3.1
collected 0 items / 1 error                                                       

===================================== ERRORS ======================================
_______________________ ERROR collecting tests/conftest.py ________________________
pytest-sphinx-venv/lib/python3.8/site-packages/pytest_sphinx.py:515: in collect
    module = self.config.pluginmanager._importconftest(
E   TypeError: _importconftest() missing 1 required positional argument: 'rootpath'

During handling of the above exception, another exception occurred:
pytest-sphinx-venv/lib/python3.8/site-packages/pytest_sphinx.py:520: in collect
    module = self.config.pluginmanager._importconftest(self.fspath)
E   TypeError: _importconftest() missing 2 required positional arguments: 'importmode' and 'rootpath'
================================ warnings summary =================================
pytest-sphinx-venv/lib/python3.8/site-packages/_pytest/nodes.py:140
pytest-sphinx-venv/lib/python3.8/site-packages/_pytest/nodes.py:140
  /tmp/sphinx-doctest/pytest-sphinx-venv/lib/python3.8/site-packages/_pytest/nodes.py:140: PytestRemovedIn8Warning: The (fspath: py.path.local) argument to SphinxDoctestModule is deprecated. Please use the (path: pathlib.Path) argument instead.
  See https://docs.pytest.org/en/latest/deprecations.html#fspath-argument-for-node-constructors-replaced-with-pathlib-path
    return super().__call__(*k, **kw)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
============================= short test summary info =============================
ERROR tests/conftest.py - TypeError: _importconftest() missing 2 required positi...
!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!
========================== 2 warnings, 1 error in 0.04s ===========================

This error happens with pytest==7.0.0 and pytest==7.0.1, but does not happen with pytest==6.2.5.

twmr commented 2 years ago

Thx for the report! I'll have a look today.