Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
GuillaumeFavelier opened this issue Mar 13, 2020 · 1 comment · Fixed by #12
Closed

Comments

@GuillaumeFavelier
Copy link

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:

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

@twmr
Copy link
Owner

twmr commented Apr 1, 2020

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

twmr added a commit that referenced this issue Apr 1, 2020
The Node API was changed in pytest 5.4 in
pytest-dev/pytest#5975.

This commit adds support for the new API but maintains backwards
compatiblity.

Closes: #11
twmr added a commit that referenced this issue Apr 1, 2020
The Node API was changed in pytest 5.4 in
pytest-dev/pytest#5975.

This commit adds support for the new API but maintains backwards
compatiblity.

Closes: #11
twmr added a commit that referenced this issue Apr 1, 2020
The Node API was changed in pytest 5.4 in
pytest-dev/pytest#5975.

This commit adds support for the new API but maintains backwards
compatiblity.

Closes: #11
@twmr twmr closed this as completed in #12 Apr 1, 2020
twmr added a commit that referenced this issue Apr 1, 2020
The Node API was changed in pytest 5.4 in
pytest-dev/pytest#5975.

This commit adds support for the new API but maintains backwards
compatiblity.

Closes: #11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants