Skip to content

fix: PYAUTOFIT_TEST_MODE is a dead env var — aggregator test-mode fixture is a silent no-op #95

Closed

Description

@Jammy2211

Overview

The canonical test-mode knob is PYAUTO_TEST_MODE (read authoritatively in PyAutoNerves/autonerves/test_mode.py:14 via os.environ.get("PYAUTO_TEST_MODE", "0"), alongside PYAUTO_TEST_MODE_SAMPLES). Nothing anywhere reads PYAUTOFIT_TEST_MODE — verified by grep across every library and workspace repo.

test_autocti/aggregator/conftest.py uses the dead name in an autouse=True fixture, so the entire aggregator test module intends to run in test mode but never enters it.

Plan

  • Rename PYAUTOFIT_TEST_MODE → PYAUTO_TEST_MODE in test_autocti/aggregator/conftest.py (the set_test_mode fixture).
  • Run the aggregator suite afterwards — enabling test mode for the first time may surface previously-masked behaviour (test mode namespaces output paths and can bypass sampling).
  • Companion docstring fix in PyAutoFit (separate PR, same task): autofit/non_linear/analysis/visualize.py Visualizer.should_visualize says "If PyAutoFit test mode is on" — naming the product rather than the variable is what leads readers to invent the wrong env var. Name PYAUTO_TEST_MODE explicitly.
Detailed implementation plan

Affected Repositories

  • PyAutoCTI (primary) — the real bug
  • PyAutoFit — one misleading docstring

Suggested branch: feature/testmode-env-drift

The bug

test_autocti/aggregator/conftest.py:13-17

@pytest.fixture(autouse=True)
def set_test_mode():
    os.environ["PYAUTOFIT_TEST_MODE"] = "1"   # <- nothing reads this
    yield
    del os.environ["PYAUTOFIT_TEST_MODE"]

Why it persisted

autocti_workspace_test/AGENTS.md:42 and autocti_assistant/skills/ac_fit_cti_model.md:126 already document that PYAUTOFIT_TEST_MODE does not exist. The trap was documented instead of deleted; this issue deletes it.

Out of scope (local-only, no PR)

Two gitignored .claude/settings.local.json allowlists (euclid_strong_lens_modeling_pipeline, autogalaxy_workspace) also use the dead name, meaning those allowlisted commands run without test mode. Fixed locally, not shipped.

Verification

  • pytest test_autocti/aggregator green with the corrected var.
  • Confirm the fixture actually takes effect (test mode active during those tests).

Activity

  1. Jammy2211 commented on Jul 22, 2026

    @Jammy2211
    CollaboratorAuthor

    Correction to the plan above: the fix is to DELETE the fixture, not rename it.

    The issue body proposed renaming PYAUTOFIT_TEST_MODE → PYAUTO_TEST_MODE. Testing showed that is the wrong fix. Making the variable live means test mode genuinely takes effect, which bypasses sampling — so the aggregator has no samples to iterate and 6 of the 13 aggregator tests fail. Those tests were written against, and only pass under, normal sampling.

    Measured three ways (pytest test_autocti/aggregator):

    Variant Result
    dead var present (baseline, main) 13 passed
    renamed to PYAUTO_TEST_MODE 6 failed, 7 passed
    fixture deleted 13 passed

    Deleting is behaviour-preserving and removes the trap outright, so that is what shipped.

    PRs: #96 (delete fixture) · PyAutoLabs/PyAutoFit#1417 (docstring names the real variable).

    Also revised: the two gitignored .claude/settings.local.json allowlists are deliberately left alone. Rewriting PYAUTOFIT_TEST_MODE=1 → PYAUTO_TEST_MODE=1 there would change what those commands do (they have always run as normal full runs). They are stale permission strings, not a defect.

  2. Jammy2211 commented on Jul 22, 2026

    @Jammy2211
    CollaboratorAuthor

    Both PRs merged: #96 (dead fixture deleted) and PyAutoLabs/PyAutoFit#1417 (docstring now names PYAUTO_TEST_MODE). Aggregator suite verified 13 passed with the fixture removed — behaviour-preserving. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions