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

Fix pytest8 jupyternbcollector #83

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
- 'v*'
pull_request:

workflow_dispatch:

jobs:

pre-commit:
Expand Down
3 changes: 2 additions & 1 deletion pytest_notebook/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

"""
import os
from pathlib import Path
import shlex

import pytest
Expand Down Expand Up @@ -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)

Expand Down
38 changes: 38 additions & 0 deletions tests/test_plugin_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
"/.../<filename>.ipynb",
),
(
"/cells/*/outputs/*/text",
"rootdir\\:\\s\\/([A-z0-9-_+]+\\/)*[A-z0-9-_+]+",
"rootdir: /.../<dir>",
),
(
"/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=/.../<dir>",
),
(
"/cells/*/outputs/*/traceback",
"\\<ipython\\-input\\-[\\-0-9a-zA-Z]*\\>",
"<ipython-input-XXXX>",
),
),
}
)
)
Expand Down
3 changes: 3 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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=/.../<dir>"
/cells/*/outputs/*/traceback \<ipython\-input\-[\-0-9a-zA-Z]*\> "<ipython-input-XXXX>"

# work around PermissionErrors in /tmp dirs by test_run_fail() test
addopts = --basetemp=tmp
Loading