From 6c7cc5101564994bd9cfe265a6c87dc4d32bb652 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 ee3ff29..306da09 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 59b7b255949c8400151d305eb87497d5da8a0b10 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 306da09..935a3da 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 467f3e9027698ca88cd415442c03627fa1d34d38 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 935a3da..ebcad2c 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}")