test: skip-if-missing guards for the [optional] sampler/astropy tests (#1511) - #1512
Merged
Merged
Conversation
`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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1511.
What
Adds skip-if-missing guards to the tests that need
[optional]-extra packages(
nautilus-sampler,astropy), following the pattern already used bytest_blackjax_nuts.py:14,nest/nss/test_search.py:20andtest_fork_context.py:31.non_linear/search/nest/test_nautilus.pyrequires_nautilusontest__single_core_builds_no_pool(the only test there that runs a realfit)database/test_file_types.pypytest.importorskip("astropy")— module-level importnon_linear/paths/test_save_and_load.pypytest.importorskip("astropy")— module-level importaggregator/summary_files/test_aggregate_fits.pypytestmark = requires_astropy— every test is FITSaggregator/test_reference.pyrequires_astropyon the 5 database/info testsaggregator/test_scrape.pyrequires_astropyon the 2_add_filestestsaggregator/test_child_analysis.pyrequires_astropyon the 2 aggregator testsTests only — no
autofit/source is touched, so no behaviour or API change.Why
test__single_core_builds_no_poolruns a realsearch.fit, which reachesfrom nautilus import Sampler(nautilus/search.py:238).nautilus-samplerships onlyin the
[optional]extra, and the test had no guard — so it hard-failed withModuleNotFoundErrorin any env without those extras, while passing in CI (which doesinstall
[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, eachone spending a control run to re-disprove it.
astropywas the same story — twocollection errors and nine aggregator errors, all missing-dependency.
Verification
Three envs, all on this branch:
3 passed, 1 skippedastropy1985 passed, 33 skipped, 0 failed, 0 errors(before: 2 collection errors, then 4 failed / 9 errors)[optional]extras — the CI env2024 passed, 3 skippedThat 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@a639226in the samevenv, before any edit.
Note on formatting
blackreports pre-existing reformat candidates in several of these files (e.g. a longraise AssertionError(...)intest_nautilus.pythat predates this branch). Left alone— formatting is advisory and not gated per
AGENTS.md, and reformatting would bury a79-line diff in unrelated churn.
🤖 Generated with Claude Code
https://claude.ai/code/session_01F1uQdHt11NPBc5cXA5cvme
Generated by Claude Code