Skip to content

test: skip-if-missing guards for the [optional] sampler/astropy tests (#1511) - #1512

Merged
Jammy2211 merged 1 commit into
mainfrom
claude/test-nautilus-single-core-builds-35kyot
Aug 22, 2026
Merged

test: skip-if-missing guards for the [optional] sampler/astropy tests (#1511)#1512
Jammy2211 merged 1 commit into
mainfrom
claude/test-nautilus-single-core-builds-35kyot

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Closes #1511.

What

Adds skip-if-missing guards to the tests that need [optional]-extra packages
(nautilus-sampler, astropy), following the pattern already used by
test_blackjax_nuts.py:14, nest/nss/test_search.py:20 and test_fork_context.py:31.

file guard
non_linear/search/nest/test_nautilus.py requires_nautilus on test__single_core_builds_no_pool (the only test there that runs a real fit)
database/test_file_types.py pytest.importorskip("astropy") — module-level import
non_linear/paths/test_save_and_load.py pytest.importorskip("astropy") — module-level import
aggregator/summary_files/test_aggregate_fits.py pytestmark = requires_astropy — every test is FITS
aggregator/test_reference.py requires_astropy on the 5 database/info tests
aggregator/test_scrape.py requires_astropy on the 2 _add_files tests
aggregator/test_child_analysis.py requires_astropy on the 2 aggregator tests

Tests only — no autofit/ source is touched, so no behaviour or API change.

Why

test__single_core_builds_no_pool runs a real search.fit, which reaches
from nautilus import Sampler (nautilus/search.py:238). nautilus-sampler ships only
in the [optional] extra, and the test had no guard — so it hard-failed with
ModuleNotFoundError in any env without those extras, while passing in CI (which does
install [optional]).

The cost was not the failure itself but the misreading: that one test has been reported
as "pre-existing on clean main" in at least six task records since 2026-08-16, each
one spending a control run to re-disprove it. astropy was the same story — two
collection errors and nine aggregator errors, all missing-dependency.

Verification

Three envs, all on this branch:

env result
no extras at all nautilus test skips with its reason — 3 passed, 1 skipped
no astropy 1985 passed, 33 skipped, 0 failed, 0 errors (before: 2 collection errors, then 4 failed / 9 errors)
full [optional] extras — the CI env 2024 passed, 3 skipped

That last line is identical to CI on main
(run 32546158666:
2024 passed, 3 skipped), which is the point — the guards are inert wherever the extras
are installed, so nothing that runs today stops running and no coverage is lost.

Baseline for the first two rows was measured on untouched main @ a639226 in the same
venv, before any edit.

Note on formatting

black reports pre-existing reformat candidates in several of these files (e.g. a long
raise AssertionError(...) in test_nautilus.py that predates this branch). Left alone
— formatting is advisory and not gated per AGENTS.md, and reformatting would bury a
79-line diff in unrelated churn.

🤖 Generated with Claude Code

https://claude.ai/code/session_01F1uQdHt11NPBc5cXA5cvme


Generated by Claude Code

`test_nautilus.py::test__single_core_builds_no_pool` runs a real
`search.fit`, which imports `nautilus` — a package that ships only via the
`[optional]` extras. With no skip guard it hard-failed with
`ModuleNotFoundError: No module named 'nautilus'` in every env installed
without those extras (cloud sandboxes, local venvs), while passing in CI,
which does install `[optional]`.

That single test has been misreported as "pre-existing on clean main" in at
least six task records since 2026-08-16, costing a control-run each time.
It is not a defect on main: main is green (2024 passed, 3 skipped).

The same class of noise came from `astropy`: two modules failed collection
outright on its top-level import, and nine aggregator tests errored on it at
runtime.

Guards follow the existing house pattern (`test_blackjax_nuts.py`,
`nest/nss/test_search.py`): an `importlib.util.find_spec` skipif marker, or
`pytest.importorskip` where the import is module-level.

Verified three ways on this branch:
- no extras at all: the nautilus test skips with its reason; 3 passed, 1 skipped
- no astropy: 1985 passed, 33 skipped, 0 failed, 0 errors
  (was: 2 collection errors, then 4 failed / 9 errors)
- full `[optional]` extras, i.e. the CI env: 2024 passed, 3 skipped —
  identical to CI on main, so the guards are inert where the deps exist and
  no coverage is lost.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01F1uQdHt11NPBc5cXA5cvme
@Jammy2211
Jammy2211 merged commit 14eb839 into main Aug 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: [optional]-dependency tests have no skip guards — a recurring false "pre-existing failure on main"

1 participant