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

Deprication warnings from Pytest #139

Closed
ocampor opened this issue Mar 22, 2020 · 7 comments · Fixed by #152
Closed

Deprication warnings from Pytest #139

ocampor opened this issue Mar 22, 2020 · 7 comments · Fixed by #152

Comments

@ocampor
Copy link

ocampor commented Mar 22, 2020

Problem Description

I run some tests using nbval that raised the following warnings:

  • PytestDeprecationWarning: direct construction of IPyNbFile has been deprecated, please use IPyNbFile.from_parent return IPyNbFile(path, parent)
  • PytestDeprecationWarning: direct construction of IPyNbCell has been deprecated, please use IPyNbCell.from_parent
    cell, options)
  • DeprecationWarning: KernelManager._kernel_spec_manager_changed is deprecated in traitlets 4.1: use @observe and @unobserve instead.
    def _kernel_spec_manager_changed(self):

Environment Details:

Pytest Version: 5.4.1
Python Version: 3.7
Nbval Version: 0.9.5

I can probably create a PR to fix these issues if you want.

@vidartf
Copy link
Collaborator

vidartf commented Mar 23, 2020

I can probably create a PR to fix these issues if you want.

PRs are always welcome :)

@GuillaumeFavelier
Copy link

I have the exact same behaviour with pytest 5.4.3

@bretttully
Copy link

Has anyone had a crack at this yet? It is now an error, rather than a warning:

============================= test session starts ==============================
platform linux -- Python 3.7.8, pytest-6.0.0, py-1.9.0, pluggy-0.13.1
rootdir: /root/***
plugins: cov-2.10.0, nbval-0.9.5
collected 0 items / 1 error
==================================== ERRORS ====================================
________________________ ERROR collecting test session _________________________
../_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pla/lib/python3.7/site-packages/pluggy/hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
../_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pla/lib/python3.7/site-packages/pluggy/manager.py:93: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
../_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pla/lib/python3.7/site-packages/pluggy/manager.py:87: in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
../_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pla/lib/python3.7/site-packages/nbval/plugin.py:115: in pytest_collect_file
    return IPyNbFile(path, parent)
../_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pla/lib/python3.7/site-packages/_pytest/nodes.py:95: in __call__
    warnings.warn(NODE_USE_FROM_PARENT.format(name=self.__name__), stacklevel=2)
E   pytest.PytestDeprecationWarning: Direct construction of IPyNbFile has been deprecated, please use IPyNbFile.from_parent.
E   See https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent for more details.

takluyver added a commit to takluyver/nbval that referenced this issue Jul 29, 2020
tlvu added a commit to tlvu/cookiecutter-birdhouse that referenced this issue Jul 29, 2020
…compatible with latest pytest 6.0.0

See computationalmodelling/nbval#139

Error from Finch Travis-CI build https://travis-ci.org/github/bird-house/finch/jobs/713031486

$ make test-notebooks
Copying notebook output sanitizer ...
Running notebook-based tests
============================= test session starts ==============================
platform linux -- Python 3.7.8, pytest-6.0.0, py-1.9.0, pluggy-0.13.1 -- /home/travis/miniconda/envs/finch/bin/python
cachedir: .pytest_cache
rootdir: /home/travis/build/bird-house/finch, configfile: setup.cfg
plugins: nbval-0.9.5, notebook-0.6.0, flake8-1.0.6
collected 0 items / 1 error

==================================== ERRORS ====================================
________________________ ERROR collecting test session _________________________
Traceback (most recent call last):
  File "/home/travis/miniconda/envs/finch/lib/python3.7/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/home/travis/miniconda/envs/finch/lib/python3.7/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/travis/miniconda/envs/finch/lib/python3.7/site-packages/pluggy/manager.py", line 87, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "/home/travis/miniconda/envs/finch/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
    return outcome.get_result()
  File "/home/travis/miniconda/envs/finch/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/travis/miniconda/envs/finch/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/home/travis/miniconda/envs/finch/lib/python3.7/site-packages/nbval/plugin.py", line 115, in pytest_collect_file
    return IPyNbFile(path, parent)
  File "/home/travis/miniconda/envs/finch/lib/python3.7/site-packages/_pytest/nodes.py", line 95, in __call__
    warnings.warn(NODE_USE_FROM_PARENT.format(name=self.__name__), stacklevel=2)
pytest.PytestDeprecationWarning: Direct construction of IPyNbFile has been deprecated, please use IPyNbFile.from_parent.
See https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent for more details.
=========================== short test summary info ============================
ERROR  - pytest.PytestDeprecationWarning: Direct construction of IPyNbFile ha...
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.14s ===============================
Makefile:128: recipe for target 'test-notebooks' failed
make: *** [test-notebooks] Error 2
@omry
Copy link

omry commented Jul 30, 2020

Thanks for fixing.
As this is fixing a major issue, do you mind pushing up an updated package?

@takluyver
Copy link
Member

@omry - Vidar already did, version 0.9.6.

@omry
Copy link

omry commented Jul 30, 2020

Oh great. I was fooled by pypi search which is still showing the old version.
image

@jli
Copy link

jli commented Dec 3, 2020

tl;dr The 3rd DeprecationWarning listed in the original issue is still happening. It's due to jupyter_client. They've fixed the issue, but haven't done a new release yet.

The DeprecationWarning isn't causing a failure for me, even on pytest-6.1.2. With a minimal Python 3 notebook (just 1 code cell: 1+1), here's the output (lightly edited):

% pytest --nbval nbval_deprecation_test.ipynb
===================================== test session starts ======================================
platform darwin -- Python 3.9.0, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
rootdir: .../my-repo, configfile: pytest.ini
plugins: nbval-0.9.6, cov-2.10.1
collected 1 item

nbval_deprecation_test.ipynb .                                                           [100%]

======================================= warnings summary =======================================
.../nbval_deprecation_test.ipynb::Cell 0
  .../lib/python3.9/site-packages/jupyter_client/manager.py:66: DeprecationWarning: KernelManager._kernel_spec_manager_changed is deprecated in traitlets 4.1: use @observe and @unobserve instead.
    def _kernel_spec_manager_changed(self):

-- Docs: https://docs.pytest.org/en/stable/warnings.html
================================= 1 passed, 1 warning in 1.28s =================================

It seems like this is a jupyter_client issue, fixed on 2020-11-11: jupyter/jupyter_client#588

There hasn't been a jupyter_client release that includes the fix, though.

Zeitsperre pushed a commit to bird-house/cookiecutter-birdhouse that referenced this issue Jan 5, 2021
…compatible with latest pytest 6.0.0

See computationalmodelling/nbval#139

Error from Finch Travis-CI build https://travis-ci.org/github/bird-house/finch/jobs/713031486

$ make test-notebooks
Copying notebook output sanitizer ...
Running notebook-based tests
============================= test session starts ==============================
platform linux -- Python 3.7.8, pytest-6.0.0, py-1.9.0, pluggy-0.13.1 -- /home/travis/miniconda/envs/finch/bin/python
cachedir: .pytest_cache
rootdir: /home/travis/build/bird-house/finch, configfile: setup.cfg
plugins: nbval-0.9.5, notebook-0.6.0, flake8-1.0.6
collected 0 items / 1 error

==================================== ERRORS ====================================
________________________ ERROR collecting test session _________________________
Traceback (most recent call last):
  File "/home/travis/miniconda/envs/finch/lib/python3.7/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/home/travis/miniconda/envs/finch/lib/python3.7/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/travis/miniconda/envs/finch/lib/python3.7/site-packages/pluggy/manager.py", line 87, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "/home/travis/miniconda/envs/finch/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
    return outcome.get_result()
  File "/home/travis/miniconda/envs/finch/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/travis/miniconda/envs/finch/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/home/travis/miniconda/envs/finch/lib/python3.7/site-packages/nbval/plugin.py", line 115, in pytest_collect_file
    return IPyNbFile(path, parent)
  File "/home/travis/miniconda/envs/finch/lib/python3.7/site-packages/_pytest/nodes.py", line 95, in __call__
    warnings.warn(NODE_USE_FROM_PARENT.format(name=self.__name__), stacklevel=2)
pytest.PytestDeprecationWarning: Direct construction of IPyNbFile has been deprecated, please use IPyNbFile.from_parent.
See https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent for more details.
=========================== short test summary info ============================
ERROR  - pytest.PytestDeprecationWarning: Direct construction of IPyNbFile ha...
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.14s ===============================
Makefile:128: recipe for target 'test-notebooks' failed
make: *** [test-notebooks] Error 2
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.

7 participants