From 0609727b0dda6784aad157669091afee79c395dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sipo=CC=8Bcz?= Date: Mon, 16 Jun 2025 19:33:25 -0700 Subject: [PATCH 1/3] ENH: skip file after failure --- nbval/plugin.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/nbval/plugin.py b/nbval/plugin.py index 08bd88d..1c2ebab 100644 --- a/nbval/plugin.py +++ b/nbval/plugin.py @@ -926,3 +926,19 @@ def _indent(s, indent=' '): if isinstance(s, str): return '\n'.join(('%s%s' % (indent, line) for line in s.splitlines())) return s + + +skip_modules = [] + + +@pytest.hookimpl(trylast=True, hookwrapper=True) +def pytest_runtest_makereport(item, call): + outcome = yield + + if outcome.get_result().failed: + skip_modules.append(item.path) + + +def pytest_runtest_call(item): + if item.path in skip_modules: + pytest.skip(f"Due to the previous failure skipping rest of tests in {item.path}") From b4964980a27d1d29868f1f60385b08a282f014ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Mon, 16 Jun 2025 20:49:13 -0700 Subject: [PATCH 2/3] ENH: use log report as it happens comes later and rerunfailures uses it --- nbval/plugin.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/nbval/plugin.py b/nbval/plugin.py index 1c2ebab..f5ace03 100644 --- a/nbval/plugin.py +++ b/nbval/plugin.py @@ -931,12 +931,11 @@ def _indent(s, indent=' '): skip_modules = [] -@pytest.hookimpl(trylast=True, hookwrapper=True) -def pytest_runtest_makereport(item, call): - outcome = yield +@pytest.hookimpl(trylast=True) +def pytest_runtest_logreport(report): - if outcome.get_result().failed: - skip_modules.append(item.path) + if 'failed' in report.outcome: + skip_modules.append(report.fspath) def pytest_runtest_call(item): From 5d538a2ad26cc0f5899c2bf9207dec393fef7455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Mon, 16 Jun 2025 20:50:34 -0700 Subject: [PATCH 3/3] ENH: item and report uses absolute vs relative paths, changing both to resolved Pathlib. --- nbval/plugin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nbval/plugin.py b/nbval/plugin.py index f5ace03..125a74f 100644 --- a/nbval/plugin.py +++ b/nbval/plugin.py @@ -928,16 +928,16 @@ def _indent(s, indent=' '): return s -skip_modules = [] +skip_modules = set() @pytest.hookimpl(trylast=True) def pytest_runtest_logreport(report): if 'failed' in report.outcome: - skip_modules.append(report.fspath) + skip_modules.add(Path(report.fspath).resolve()) def pytest_runtest_call(item): - if item.path in skip_modules: + if Path(item.path) in skip_modules: pytest.skip(f"Due to the previous failure skipping rest of tests in {item.path}")