Skip to content

Commit 9573ef0

Browse files
authored
Merge pull request #203 from computationalmodelling/pytest-collect-pathlib
Switch collection hook to use pathlib paths
2 parents d7bc348 + 5f56fae commit 9573ef0

File tree

5 files changed

+22
-25
lines changed

5 files changed

+22
-25
lines changed

appveyor.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ image: Visual Studio 2019
66
# environment variables
77
environment:
88
matrix:
9-
- PYTHON: "C:\\Python36-x64"
109
- PYTHON: "C:\\Python37-x64"
1110
- PYTHON: "C:\\Python38-x64"
1211
- PYTHON: "C:\\Python39-x64"

docs/environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ dependencies:
77
- matplotlib
88
- sphinx
99
- nbsphinx>=0.3.1
10+
- sphinx-rtd-theme

nbval/plugin.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -134,21 +134,14 @@ def pytest_configure(config):
134134

135135

136136

137-
def pytest_collect_file(path, parent):
137+
def pytest_collect_file(file_path, parent):
138138
"""
139139
Collect IPython notebooks using the specified pytest hook
140140
"""
141141
opt = parent.config.option
142-
if (opt.nbval or opt.nbval_lax) and path.fnmatch("*.ipynb"):
142+
if (opt.nbval or opt.nbval_lax) and file_path.suffix == ".ipynb":
143143
# https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent
144-
if hasattr(IPyNbFile, "from_parent"):
145-
try: # Pytest >= 7.0.0
146-
return IPyNbFile.from_parent(parent, path=Path(path))
147-
except AssertionError:
148-
return IPyNbFile.from_parent(parent, fspath=path)
149-
else: # Pytest < 5.4
150-
return IPyNbFile(path, parent)
151-
144+
return IPyNbFile.from_parent(parent, path=file_path)
152145

153146

154147
comment_markers = {
@@ -351,13 +344,9 @@ def collect(self):
351344
options.update(comment_opts)
352345
options.setdefault('check', self.compare_outputs)
353346
name = 'Cell ' + str(cell_num)
354-
# https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent
355-
if hasattr(IPyNbCell, "from_parent"):
356-
yield IPyNbCell.from_parent(
357-
self, name=name, cell_num=cell_num, cell=cell, options=options
358-
)
359-
else:
360-
yield IPyNbCell(name, self, cell_num, cell, options)
347+
yield IPyNbCell.from_parent(
348+
self, name=name, cell_num=cell_num, cell=cell, options=options
349+
)
361350

362351
# Update 'code' cell count
363352
cell_num += 1

readthedocs.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
type: sphinx
2-
python:
3-
version: 3.8
4-
pip_install: true
1+
version: 2
2+
3+
build:
4+
os: "ubuntu-22.04"
5+
tools:
6+
python: "mambaforge-latest"
7+
58
conda:
6-
file: docs/environment.yml
9+
environment: docs/environment.yml
10+
11+
python:
12+
install:
13+
- method: pip
14+
path: .

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
]
2222
},
2323
install_requires = [
24-
'pytest >= 2.8',
24+
'pytest >= 7',
2525
'jupyter_client',
2626
'nbformat',
2727
'ipykernel',
2828
'coverage',
2929
],
30-
python_requires='>=3.6, <4',
30+
python_requires='>=3.7, <4',
3131
classifiers = [
3232
'Framework :: IPython',
3333
'Framework :: Pytest',

0 commit comments

Comments
 (0)