Skip to content

test(cli): test modules repeat no floor reset, define each shared fixture once, and hold no tests of test helpers #2173

Closed

Description

@dan-petty

What happened

The test-suite audit of 2026-10-24 at df8e2ee found setup code and tests that cost time and add no check of src/:

Autouse fixtures that repeat a reset of the floor (15). The floor calls every reset in _PROCESS_STATE_RESETS after each test, so these module fixtures do again what the floor already did:
tests/test_k8s_service_proxy.py:24, tests/test_secret_resolution.py:46, tests/test_telemetry_logfire.py:40, tests/test_rag_kb_sync.py:116, tests/test_gitignore_evaluation.py:19, tests/test_ai_request_priority.py:27, tests/test_k8s_service.py:25, tests/test_ollama_dynamic_leasing.py:20, tests/test_fastmcp_contracts.py:808, tests/test_k8s_context_resolution.py:14, tests/test_config_field_validation.py:32, tests/test_rag_investigator.py:28, tests/test_ci_dry_run.py:18, tests/test_consolidation_dry_run_decorator.py:15 and tests/test_review_rules_pack.py:41.

Fixtures defined again in several modules. project in tests/test_ci_repeat.py:75, tests/test_review_regression_harness.py:40, tests/test_test_runner.py:61 and tests/test_test_selection.py:44; tree in tests/test_review_tool_runs.py:89, tests/test_review_tool_sandbox.py:43, tests/test_sandbox_tool_executor.py:41 and tests/test_scanner_tool_executor.py:67.

Tests whose subject is a test helper, not src/.

  • tests/test_model_fixture.py:29-115: 8 tests of ModelFake, which tests/test_model_contract.py already covers.
  • tests/test_support_waits.py: tests of tests/support/waits.py; one case waits 1.5 s of real time.
  • tests/test_support_hung_children.py:45: a test of tests/support/hung_children.py that starts sh.
  • tests/test_per_test_timeout.py: runs a hanging test in an inner pytest session to check the pytest-timeout setting (4.2 s).
  • tests/test_openblas_worker_threads.py: starts python to check an environment variable of the root conftest, and skips where /proc/self/status is missing.

An input much larger than its case needs. tests/test_semgrep_registry.py:226 builds a YAML body nested 100,000 levels deep to check that the loader refuses it. The audit measured about 10 s for each case on the CI runner. A depth just past the limit that the loader enforces gives the same refusal.

What should happen

  • The 15 fixtures go.
  • A fixture with the same body in several modules moves to tests/support/. A fixture with a different body gets a name that says what it builds.
  • The tests of test helpers go. A setting of pytest or of the root conftest that must hold is checked by a devops ci row, not by a test that starts pytest or python.
  • The nested-YAML case builds the smallest body that passes the loader's limit, with the depth read from that limit.

Evidence

  • .data/agent/scratch/audit/full_list.txt of the 2026-10-24 audit: sections 5.autouse-in-test-modules, 5.fixtures-defined-in-many-places, 4.tests-of-fakes-or-helpers, 4.expensive-inputs and class 6.
  • tests/conftest.py:83-134 at b170358: _PROCESS_STATE_RESETS.

Acceptance criteria

  • None of the 15 fixtures is left, and no other module fixture calls a reset that _PROCESS_STATE_RESETS holds.
  • project and tree are each defined in one place, or their copies have distinct names.
  • The five helper-test files are deleted. Any setting they guarded is a devops ci row, and the pull request shows the row failing on a broken setting.
  • The nested-YAML case still refuses the body with the same error, and the pull request gives its time before and after.
  • uv run devops ci passes.

Out of scope: the module-level runner = CliRunner() bindings belong to #1307's children (Q14). The duplicated _public_endpoints and _bypass_dns_validation fixtures patch devops_cli names, so #1331, #1328 and #2167 remove them. The CONFIG_PATH patch at tests/test_ai_task_settings_paths.py:30 belongs to #1333.

Proposed design

Problem statement

The test suite carries 15 autouse fixtures that repeat resets the conftest floor already performs, two fixtures defined in four modules each, five test files that test test helpers instead of src/, and one test input 100,000 levels deep where a depth just past the loader limit suffices. These cost CI time and add no check of production code.

Acceptance criteria

  • Criterion 1: None of the 15 listed autouse fixtures remains in its module, and no other module fixture calls a reset that _PROCESS_STATE_RESETS holds.
    Verification: Run uv run pytest tests/ -x and confirm no collection error. Grep the 15 listed files for the fixture names and confirm they are absent. Run uv run devops ci and confirm the architectural-invariant check passes.
  • Criterion 2: The project fixture is defined in one place, or its four copies carry distinct names that say what each builds.
    Verification: Grep tests/ for the fixture definition of project. Confirm at most one definition remains, or that the remaining copies have distinct names. Run uv run pytest on the four affected modules and confirm they pass.
  • Criterion 3: The tree fixture is defined in one place, or its four copies carry distinct names that say what each builds.
    Verification: Grep tests/ for the fixture definition of tree. Confirm at most one definition remains, or that the remaining copies have distinct names. Run uv run pytest on the four affected modules and confirm they pass.
  • Criterion 4: The five helper-test files are deleted: test_model_fixture.py, test_support_waits.py, test_support_hung_children.py, test_per_test_timeout.py, test_openblas_worker_threads.py.
    Verification: Confirm the five files are absent from tests/. Run uv run pytest tests/ -x and confirm no import or collection error references them.
  • Criterion 5: Every pytest or conftest setting the deleted tests guarded is now a devops ci row, and the pull request shows that row failing on a broken setting.
    Verification: Read the devops ci configuration for the new rows. Run the row with a deliberately broken setting and confirm it fails. Run uv run devops ci with the correct setting and confirm it passes.
  • Criterion 6: The nested-YAML case in test_semgrep_registry.py builds a body whose depth is just past the loader limit, still receives the same refusal error, and the pull request records its time before and after.
    Verification: Read the loader source for the depth limit constant. Confirm the test builds a body at limit+1 depth. Run the test and confirm the same error message. Read the pull request description for before and after timings.
  • Criterion 7: uv run devops ci passes in full.
    Verification: Run uv run devops ci and confirm exit code 0 with no failing check.

Key questions

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/test
    on Oct 24, 2026
  2. dan-petty commented on Oct 24, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.

    • Type: type/test. The candidate proposes changes to test modules and their fixtures, which falls under test improvements.
    • Priority: P2-Medium. The changes improve test suite quality but do not address a critical issue or bug.
    • Value: High. Improving test efficiency and reducing redundant code benefits all developers and users by making tests faster and cleaner.
    • Effort: Medium. The candidate requires refactoring multiple test files, moving fixtures, deleting tests, and adjusting input data, which is substantial but manageable work.
    • Related: test(cli): migrate 49 tests to public interfaces #2167, which asks for a different change. Both items target test files that patch devops_cli names or import private names, but this candidate focuses on fixtures and helper tests while the related item focuses on ownership and internal patches.
  3. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Status set to Ready at bb46660 (see proposed design in issue body).

  4. added
    priority/p2-medium
    status/ready
    effort/medium
    value/high
    scope/cli
    on Oct 28, 2026
  5. removed
    status/ready
    on Oct 31, 2026
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

    effort/mediumpriority/p2-mediumscope/clisource/agenttype/testvalue/high

    Type

    No type

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions