Skip to content

pytest-sphinx is not working with pytest v5.4.0 (released on March 12th 2020) #11

Closed

Description

@GuillaumeFavelier

pytest-sphinx is not working with pytest v5.4.0 (released on March 12th 2020):

plugins: qt-3.3.0, sugar-0.9.2, sphinx-0.2.2, timeout-1.3.4, cov-2.8.1, mock-2.0.0
collecting ... 
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ERROR collecting test session ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
../anaconda3/envs/mne-pyvista/lib/python3.7/site-packages/pluggy/hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
        args       = ()
        kwargs     = {'parent': <Session mne-python exitstatus=<ExitCode.OK: 0> testsfailed=0 testscollected=0>,
 'path': local('/home/guillaume/source/mne-python/mne/viz/_brain/__init__.py')}
        notincall  = set()
        self       = <_HookCaller 'pytest_collect_file'>
../anaconda3/envs/mne-pyvista/lib/python3.7/site-packages/pluggy/manager.py:93: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
        hook       = <_HookCaller 'pytest_collect_file'>
        kwargs     = {'parent': <Session mne-python exitstatus=<ExitCode.OK: 0> testsfailed=0 testscollected=0>,
 'path': local('/home/guillaume/source/mne-python/mne/viz/_brain/__init__.py')}
        methods    = [<HookImpl plugin_name='python', plugin=<module '_pytest.python' from '/home/guillaume/source/anaconda3/envs/mne-pyvista/lib/python3.7/site-packages/_pytest/python.py'>>,
 <HookImpl plugin_name='doctest', plugin=<module '_pytest.doctest' from '/home/guillaume/source/anaconda3/envs/mne-pyvista/lib/python3.7/site-packages/_pytest/doctest.py'>>,
 <HookImpl plugin_name='sphinx', plugin=<module 'pytest_sphinx' from '/home/guillaume/source/anaconda3/envs/mne-pyvista/lib/python3.7/site-packages/pytest_sphinx.py'>>]
        self       = <_pytest.config.PytestPluginManager object at 0x7ff2985fe310>
../anaconda3/envs/mne-pyvista/lib/python3.7/site-packages/pluggy/manager.py:87: in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
        hook       = <_HookCaller 'pytest_collect_file'>
        kwargs     = {'parent': <Session mne-python exitstatus=<ExitCode.OK: 0> testsfailed=0 testscollected=0>,
 'path': local('/home/guillaume/source/mne-python/mne/viz/_brain/__init__.py')}
        methods    = [<HookImpl plugin_name='python', plugin=<module '_pytest.python' from '/home/guillaume/source/anaconda3/envs/mne-pyvista/lib/python3.7/site-packages/_pytest/python.py'>>,
 <HookImpl plugin_name='doctest', plugin=<module '_pytest.doctest' from '/home/guillaume/source/anaconda3/envs/mne-pyvista/lib/python3.7/site-packages/_pytest/doctest.py'>>,
 <HookImpl plugin_name='sphinx', plugin=<module 'pytest_sphinx' from '/home/guillaume/source/anaconda3/envs/mne-pyvista/lib/python3.7/site-packages/pytest_sphinx.py'>>]
../anaconda3/envs/mne-pyvista/lib/python3.7/site-packages/pytest_sphinx.py:44: in pytest_collect_file
    return SphinxDoctestModule(path, parent)
        config     = <_pytest.config.Config object at 0x7ff297a66590>
        parent     = <Session mne-python exitstatus=<ExitCode.OK: 0> testsfailed=0 testscollected=0>
        path       = local('/home/guillaume/source/mne-python/mne/viz/_brain/__init__.py')
../anaconda3/envs/mne-pyvista/lib/python3.7/site-packages/_pytest/nodes.py:83: in __call__
    warnings.warn(NODE_USE_FROM_PARENT.format(name=self.__name__), stacklevel=2)
E   pytest.PytestDeprecationWarning: direct construction of SphinxDoctestModule has been deprecated, please use SphinxDoctestModule.from_parent
        __class__  = <class '_pytest.nodes.NodeMeta'>
        k          = (local('/home/guillaume/source/mne-python/mne/viz/_brain/__init__.py'),
 <Session mne-python exitstatus=<ExitCode.OK: 0> testsfailed=0 testscollected=0>)
        kw         = {}
        self       = <class 'pytest_sphinx.SphinxDoctestModule'>

--------------------------------------------------------------------- generated xml file: /home/guillaume/source/mne-python/junit-results.xml ----------------------------------------------------------------------
============================================================================================= short test summary info ==============================================================================================
FAILED  - pytest.PytestDeprecationWarning: direct construction of SphinxDoctestModule has been deprecated, please use SphinxDoctestModule.from_parent
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Results (0.20s):

I suggest:

Details
diff --git a/pytest_sphinx.py b/pytest_sphinx.py
index 491d351..8ab7c82 100644
--- a/pytest_sphinx.py
+++ b/pytest_sphinx.py
@@ -41,7 +41,7 @@ def pytest_collect_file(path, parent):
     config = parent.config
     if path.ext == ".py":
         if config.option.doctestmodules:
-            return SphinxDoctestModule(path, parent)
+            return SphinxDoctestModule.from_parent(parent=parent, fspath=path)
     elif _is_doctest(config, path, parent):
         return SphinxDoctestTextfile(path, parent)

Reference:
https://docs.pytest.org/en/latest/deprecations.html#node-construction-changed-to-node-from-parent

Activity

  1. twmr commented on Apr 1, 2020

    @twmr
    Owner

    Sry for the delay. I stumbled over this issue today. I'll fix it ASAP.

  2. added 3 commits that reference this issue on Apr 1, 2020
    b391be6
    8d38df8
    f9decc0
  3. added a commit that references this issue on Apr 1, 2020
    5123745
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions