chrisjsewell / pytest-notebook

A pytest plugin for regression testing and regenerating Jupyter Notebooks
https://pytest-notebook.readthedocs.io
BSD 3-Clause "New" or "Revised" License
47 stars 9 forks source link

Errors under pytest 8.0.0: A) The (fspath: py.path.local) argument to JupyterNbCollector is deprecated. B) PermissionError: [Errno 13] Permission denied #73

Open amotl opened 5 months ago

amotl commented 5 months ago

Dear Chris,

when updating to pytest 8.0.0, released two days ago, through a corresponding PR submitted by Dependabot, ...

.... CI fails like:

ERROR tests/testdata/folder - pytest.PytestRemovedIn8Warning: The (fspath: py.path.local) argument to JupyterNbCollector 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
ERROR tests/testdata/snippet - pytest.PytestRemovedIn8Warning: The (fspath: py.path.local) argument to JupyterNbCollector 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

-- https://github.com/pyveci/pueblo/actions/runs/7701648260/job/20988180571?pr=63#step:5:154

This documentation probably has corresponding guidelines.

With kind regards, Andreas.

amotl commented 5 months ago

While the previous report was coming from a downstream project, when switching to this one, the issue can be reproduced like that:

pytest -vvv tests/test_plugin_collector.py

The outcome is:

FAILED tests/test_plugin_collector.py::test_collection - Failed: nomatch: '*<JupyterNbCollector*test_nb.ipynb>*'
FAILED tests/test_plugin_collector.py::test_setup_with_skip_meta - Failed: nomatch: '*test_nb.ipynb*s*'
FAILED tests/test_plugin_collector.py::test_run_fail - Failed: nomatch: '*::nbregression(test_nb) FAILED*'
FAILED tests/test_plugin_collector.py::test_run_pass_with_meta - Failed: nomatch: '*::nbregression(test_nb) PASSED*'
amotl commented 5 months ago

GH-74 partly fixes the problem, i.e. both tests test_collection and test_setup_with_skip_meta. The other two test cases wierdly error out like that, and I can't discover anything how to fix this.

/path/to/.venv/lib/python3.11/site-packages/pluggy/_hooks.py:493: in __call__
    return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
/path/to/.venv/lib/python3.11/site-packages/pluggy/_manager.py:115: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
/path/to/.venv/lib/python3.11/site-packages/pluggy/_manager.py:457: in traced_hookexec
    return outcome.get_result()
/path/to/.venv/lib/python3.11/site-packages/pluggy/_manager.py:454: in <lambda>
    lambda: oldcall(hook_name, hook_impls, caller_kwargs, firstresult)
/path/to/.venv/lib/python3.11/site-packages/_pytest/python.py:210: in pytest_collect_directory
    if pkginit.is_file():
/usr/local/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/pathlib.py:1267: in is_file
    return S_ISREG(self.stat().st_mode)
/usr/local/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/pathlib.py:1013: in stat
    return os.stat(self, follow_symlinks=follow_symlinks)
E   PermissionError: [Errno 13] Permission denied: '/private/var/audit/__init__.py'
=========================== short test summary info ============================
ERROR ../../../../../../../../../Users/amo/dev/pyveci/sources/pytest-notebook/::private::var

Same on CI:

________________________ ERROR collecting test session _________________________
/path/to/lib/python3.8/site-packages/pluggy/_hooks.py:501: in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
/path/to/lib/python3.8/site-packages/pluggy/_manager.py:119: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
/path/to/lib/python3.8/site-packages/pluggy/_manager.py:473: in traced_hookexec
    return outcome.get_result()
/path/to/lib/python3.8/site-packages/pluggy/_manager.py:470: in <lambda>
    lambda: oldcall(hook_name, hook_impls, caller_kwargs, firstresult)
/path/to/lib/python3.8/site-packages/_pytest/python.py:210: in pytest_collect_directory
    if pkginit.is_file():
/path/to/lib/python3.8/pathlib.py:1439: in is_file
    return S_ISREG(self.stat().st_mode)
/path/to/lib/python3.8/pathlib.py:1198: in stat
    return self._accessor.stat(self)
E   PermissionError: [Errno 13] Permission denied: '/tmp/snap-private-tmp/__init__.py'
=========================== short test summary info ============================
ERROR ../../../../home/runner/work/pytest-notebook/pytest-notebook/::tmp - PermissionError: [Errno 13] Permission denied: '/tmp/snap-private-tmp/__init__.py'

-- https://github.com/chrisjsewell/pytest-notebook/actions/runs/7702860395/job/20992040778?pr=74#step:5:264