From 7e3d553f22505cbc52779c211a05fdca2102cfad Mon Sep 17 00:00:00 2001 From: Adam Gleave Date: Tue, 15 Sep 2020 20:47:14 +0100 Subject: [PATCH 01/10] Use from_parent rather than deprecated constructor --- pytest_notebook/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytest_notebook/plugin.py b/pytest_notebook/plugin.py index 7b3b158..eaf36d1 100644 --- a/pytest_notebook/plugin.py +++ b/pytest_notebook/plugin.py @@ -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): From 4b99be213ed7bc0e47578a11de33092b98059dae Mon Sep 17 00:00:00 2001 From: Adam Gleave Date: Wed, 16 Sep 2020 08:00:47 +0100 Subject: [PATCH 02/10] Pin nbconvert to last supported major version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index f4a8ed5..8a1788d 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ "pytest>=3.5.0", "attrs", "jupyter_client", - "nbconvert", + "nbconvert~=5.6.0", "nbdime", "nbformat", "jsonschema", From 58bf744408a3a8c8eb26c14b75c34880136cf122 Mon Sep 17 00:00:00 2001 From: Adam Gleave Date: Wed, 16 Sep 2020 11:28:49 +0100 Subject: [PATCH 03/10] Remove superflous f-strings to appease flake8 --- pytest_notebook/execution.py | 2 +- pytest_notebook/nb_regression.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pytest_notebook/execution.py b/pytest_notebook/execution.py index da243e3..8b13d6e 100644 --- a/pytest_notebook/execution.py +++ b/pytest_notebook/execution.py @@ -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( diff --git a/pytest_notebook/nb_regression.py b/pytest_notebook/nb_regression.py index 918177d..1d7d056 100644 --- a/pytest_notebook/nb_regression.py +++ b/pytest_notebook/nb_regression.py @@ -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), From d822363eabe721d6c9d3fe980ebcfb793bc8d913 Mon Sep 17 00:00:00 2001 From: Adam Gleave Date: Wed, 16 Sep 2020 11:48:14 +0100 Subject: [PATCH 04/10] Pin to older version of coverage with compatible CoverageData --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 8a1788d..ebc7d4d 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ ], extras_require={ "testing": [ - "coverage", + "coverage~=4.5.1", "pytest-cov", "pytest-regressions", "black==19.3b0", From 5476217274ed9d3efe56cacc2ca06b488dac7f48 Mon Sep 17 00:00:00 2001 From: Adam Gleave Date: Wed, 16 Sep 2020 11:59:46 +0100 Subject: [PATCH 05/10] Specify minor format explicitly so tests do not break on nbformat upgrades --- pytest_notebook/notebook.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytest_notebook/notebook.py b/pytest_notebook/notebook.py index af5df1f..5c0caeb 100644 --- a/pytest_notebook/notebook.py +++ b/pytest_notebook/notebook.py @@ -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 From 617faed46e8fc6dd8967ba2e0adb2589d65f90ee Mon Sep 17 00:00:00 2001 From: Adam Gleave Date: Wed, 16 Sep 2020 12:00:03 +0100 Subject: [PATCH 06/10] Pin coverage in docs too --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ebc7d4d..ddd4af2 100644 --- a/setup.py +++ b/setup.py @@ -57,7 +57,7 @@ "ipypublish>=0.10.7", "ruamel.yaml", "ruamel.yaml.clib", - "coverage", + "coverage~=4.5.1", ], }, classifiers=[ From 8978fb6e038f81b38928a533f8d5ba32104b2b4b Mon Sep 17 00:00:00 2001 From: Adam Gleave Date: Wed, 16 Sep 2020 12:05:25 +0100 Subject: [PATCH 07/10] Fix other pytest6 bug --- pytest_notebook/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytest_notebook/plugin.py b/pytest_notebook/plugin.py index eaf36d1..59cd1cd 100644 --- a/pytest_notebook/plugin.py +++ b/pytest_notebook/plugin.py @@ -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): From dc4f17323f8bdaefc961dc5b0876dcb500ff4fe5 Mon Sep 17 00:00:00 2001 From: Adam Gleave Date: Wed, 16 Sep 2020 12:11:17 +0100 Subject: [PATCH 08/10] Avoid stale attrs causing pip brokenness --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ddd4af2..d5894e7 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ include_package_data=True, install_requires=[ "pytest>=3.5.0", - "attrs", + "attrs<21,>=19", "jupyter_client", "nbconvert~=5.6.0", "nbdime", From 2288761e3a590da13a0d23552e714b3114b078bd Mon Sep 17 00:00:00 2001 From: Adam Gleave Date: Wed, 16 Sep 2020 12:17:02 +0100 Subject: [PATCH 09/10] Appease sphinx --- docs/source/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/conf.py b/docs/source/conf.py index 31bd775..7c0a5a6 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -84,6 +84,7 @@ nitpick_ignore = [ ("py:class", "NoneType"), + ("py:class", "TypeIO"), ("py:class", "attr.ib"), ("py:class", "attr.s"), ("py:class", "ruamel.yaml.dumper.RoundTripDumper"), From 9b2526f9b1e1ef4f9f46c49ec4dbf0b9eeaf88ba Mon Sep 17 00:00:00 2001 From: Adam Gleave Date: Wed, 16 Sep 2020 12:20:54 +0100 Subject: [PATCH 10/10] More ignores --- docs/source/conf.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 7c0a5a6..d1ea4b7 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -84,12 +84,13 @@ nitpick_ignore = [ ("py:class", "NoneType"), - ("py:class", "TypeIO"), + ("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