diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f2a5f03..3524778 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,6 +7,8 @@ on: - 'v*' pull_request: + workflow_dispatch: + jobs: pre-commit: diff --git a/pytest_notebook/plugin.py b/pytest_notebook/plugin.py index ab9cd3e..0c85142 100644 --- a/pytest_notebook/plugin.py +++ b/pytest_notebook/plugin.py @@ -11,6 +11,7 @@ """ import os +from pathlib import Path import shlex import pytest @@ -270,7 +271,7 @@ def pytest_collect_file(path, parent): path.fnmatch(pat) for pat in other_args.get("nb_file_fnmatch", ["*.ipynb"]) ): try: - return JupyterNbCollector.from_parent(parent, fspath=path) + return JupyterNbCollector.from_parent(parent, path=Path(path)) except AttributeError: return JupyterNbCollector(path, parent) diff --git a/tests/test_plugin_fixture.py b/tests/test_plugin_fixture.py index c98c927..5648064 100644 --- a/tests/test_plugin_fixture.py +++ b/tests/test_plugin_fixture.py @@ -67,6 +67,44 @@ def test_nb(nb_regression): # the following are the defaults for pytest-cov "cov_source": (), "cov_config": ".coveragerc", + # expected diff_replace loaded from pytest config in tox.ini + "diff_replace": ( + ( + "/cells/*/outputs/*/text", + "\\/([A-z0-9-_+]+\\/)*[A-z0-9-_+]+\\.ipynb", + "/.../.ipynb", + ), + ( + "/cells/*/outputs/*/text", + "rootdir\\:\\s\\/([A-z0-9-_+]+\\/)*[A-z0-9-_+]+", + "rootdir: /.../", + ), + ( + "/cells/*/outputs/*/text", + "in\\s[\\.0-9]+\\sseconds", + "in xxx seconds", + ), + ( + "/cells/*/outputs/*/text", + "platform\\s(darwin|linux).*\\n", + "platform info ...\\n", + ), + ( + "/cells/*/outputs/*/text", + "plugins\\:\\s.*\\n", + "plugin info ...\\n", + ), + ( + "/cells/*/outputs/*/text", + "exec_cwd\\=\\\\\\'\\/([A-z0-9-_+]+\\/)*[A-z0-9-_+]+\\\\\\'", + "exec_cwd=/.../", + ), + ( + "/cells/*/outputs/*/traceback", + "\\", + "", + ), + ), } ) ) diff --git a/tox.ini b/tox.ini index c1c9160..66a7458 100644 --- a/tox.ini +++ b/tox.ini @@ -36,3 +36,6 @@ nb_diff_replace = /cells/*/outputs/*/text plugins\:\s.*\n "plugin info ...\n" /cells/*/outputs/*/text "exec_cwd\=\\\'\/([A-z0-9-_+]+\/)*[A-z0-9-_+]+\\\'" "exec_cwd=/.../" /cells/*/outputs/*/traceback \ "" + +# work around PermissionErrors in /tmp dirs by test_run_fail() test +addopts = --basetemp=tmp