Skip to content

Fix for PyTest6 API: use from_parent rather than constructor #11

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

Closed
wants to merge 10 commits into from
2 changes: 2 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@

nitpick_ignore = [
("py:class", "NoneType"),
("py:class", "TextIO"),
("py:class", "attr.ib"),
("py:class", "attr.s"),
("py:class", "ruamel.yaml.dumper.RoundTripDumper"),
("py:exc", "nbconvert.preprocessors.CellExecutionError"),
("py:class", "nbdime.diff_format.DiffEntry"),
("py:class", "_pytest.nodes.Item"),
]

# The reST default role (used for this markup: `text`) to use for all
Expand Down
2 changes: 1 addition & 1 deletion pytest_notebook/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def preprocess(self, nb, resources, km=None):
with self.setup_preprocessor(nb, resources, km=km):
self.log.info(f"Executing notebook with kernel: {self.kernel_name}")
if self.coverage and self.kernel_name.startswith("python"):
self.log.info(f"Recording coverage for notebook")
self.log.info("Recording coverage for notebook")
self.coverage_setup(nb_version)
try:
nb, resources = super(ExecutePreprocessor, self).preprocess(
Expand Down
2 changes: 1 addition & 1 deletion pytest_notebook/nb_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def check(

# TODO merge on fail option (using pytest-cov --no-cov-on-fail)
if self.cov_merge and exec_results.has_coverage:
logger.info(f"Merging coverage.")
logger.info("Merging coverage.")
self.cov_merge.data.update(
exec_results.coverage_data(self.cov_merge.debug),
aliases=_get_coverage_aliases(self.cov_merge),
Expand Down
2 changes: 1 addition & 1 deletion pytest_notebook/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def create_notebook(as_version: int = DEFAULT_NB_VERSION):
elif as_version == 3:
notebook = nbformat.v3.new_notebook()
elif as_version == 4:
notebook = nbformat.v4.new_notebook()
notebook = nbformat.v4.new_notebook(nbformat_minor=2)
else:
raise NotImplementedError(f"notebook version: {as_version}")
return notebook
Expand Down
4 changes: 2 additions & 2 deletions pytest_notebook/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def pytest_collect_file(path, parent):
if other_args.get("nb_test_files", False) and any(
path.fnmatch(pat) for pat in other_args.get("nb_file_fnmatch", ["*.ipynb"])
):
return JupyterNbCollector(path, parent)
return JupyterNbCollector.from_parent(parent, fspath=path)


class JupyterNbCollector(pytest.File):
Expand All @@ -266,7 +266,7 @@ class JupyterNbCollector(pytest.File):
def collect(self):
"""Collect tests for the notebook."""
name = os.path.splitext(os.path.basename(self.fspath))[0]
yield JupyterNbTest(f"nbregression({name})", self)
yield JupyterNbTest.from_parent(self, name=f"nbregression({name})")


class JupyterNbTest(pytest.Item):
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
include_package_data=True,
install_requires=[
"pytest>=3.5.0",
"attrs",
"attrs<21,>=19",
"jupyter_client",
"nbconvert",
"nbconvert~=5.6.0",
"nbdime",
"nbformat",
"jsonschema",
Expand All @@ -33,7 +33,7 @@
],
extras_require={
"testing": [
"coverage",
"coverage~=4.5.1",
"pytest-cov",
"pytest-regressions",
"black==19.3b0",
Expand All @@ -57,7 +57,7 @@
"ipypublish>=0.10.7",
"ruamel.yaml",
"ruamel.yaml.clib",
"coverage",
"coverage~=4.5.1",
],
},
classifiers=[
Expand Down