Skip to content

test(core): core tests run on the process and GitHub fakes #3860

Closed

Description

@dan-petty

Problem or Motivation

Part of #1333, item 1 of its Fit note: "Core tests on edge fakes". The tests of src/devops_cli/core/process.py still reach into private state of the runner, and the JSON runner tests patch the runner function itself.

Counts on origin/main (5bc50d0), read again because the tree has moved since #1333 was written:

  • tests/core/test_consolidation_process_json.py patches devops_cli.core.process.run_subprocess 6 times.
  • tests/core/test_subprocess_env_boundary.py assigns the private process._github_token 5 times, and reads and assigns the private process._github_lookup_failure 1 time.
  • The other 14 files that test(cli): Use edge fakes and real git; drop test rebind hooks #1333 names for core hold no run_subprocess or _github_token patch any more. Earlier items removed them, and the files test_command_decorator.py, test_consolidation_cli_errors.py and test_process_pipeline.py no longer exist.

The process_fake fixture and the pinned GitHub identity (pin_github_session, reset_github_token) already exist. The tests do not use them.

Proposed Solution & Architectural Design

  • test_consolidation_process_json.py answers the child through process_fake. It patches no devops_cli name.
  • test_subprocess_env_boundary.py starts from the identity that the floor pins, or from reset_github_token() when a test needs no identity. It assigns no private name. A test that needs a token reads the one that pin_github_session yields.
  • The test of the lookup retry interval moves the clock with the clock fixture. For that, _session_github_token in core/process.py reads clock.monotonic() (the clock seam of refactor(cli): tests control time: time-machine fakes wall-clock reads, and retry and rate-limit waits return at once and are recorded #1320) in place of time.monotonic(). The behavior does not change.
  • The tests of the unauthenticated error answer gh auth token through process_fake.
  • The tests that check the environment of the child keep the stdlib subprocess.run double. They test DefaultProcessRunner, which is the real implementation of the process seam, and docs/TESTING.md allows the double of a stdlib edge.

Out of scope (other items of #1333): config, git, dry-run and root, http, exceptions/lang/models, the accommodations (async reroute, PYTEST_CURRENT_TEST, settings cache key, cache_clear), dead code, renames and splits of files, and the private imports and internal patches of the other core test files that are not about the process or the GitHub token.

Target Subsystem

SDLC, Git & PR Governance

Acceptance criteria

  • No test in tests/core/ patches devops_cli.core.process.run_subprocess.
  • No test in tests/core/ assigns or reads process._github_token or process._github_lookup_failure.
  • The retry interval of the failed lookup is tested with the clock fixture.
  • The lookup of the unauthenticated error is tested through process_fake.
  • A change of the product code (the retry, the JSON parse) makes the migrated tests fail.
  • uv run devops ci passes.

Existing Tool Considered

pytest, time-machine (the clock fixture) and the shared fakes of tests/support/fakes/ cover the need. This item builds nothing new.

Related

Parent: #1333. Tracker: #1307. ADR 0007.

Activity

  1. added
    source/agent
    type/test
    status/new
    value/medium
    effort/medium
    on Nov 6, 2026
  2. dan-petty commented on Nov 6, 2026

    @dan-petty
    OwnerAuthor

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

    • Type: type/test. The test prefix of the title gives the type.
    • Scope: none. The title has the scope core, and .github/labels.yml declares no scope/core label. Add the label to the file to give the scope to this item.
    • Priority: P2-Medium. It removes fragile private-state access in tests but does not fix a user-facing defect.
    • Value: Medium. It makes two core test files robust and aligned with the project fake strategy, but user-facing behaviour is unchanged.
    • Effort: Medium. It migrates two test files, adds a clock seam in one production function, and verifies six acceptance criteria.
    • Related: test(cli): Use edge fakes and real git; drop test rebind hooks #1333, which asks for a different change. Both target core test files using edge fakes; #1333 owns all 36 files while this candidate migrates only the two process and GitHub-token files.
  3. added
    priority/p2-medium
    on Nov 6, 2026
  4. added
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 6, 2026
  5. removed
    status/in-review
    on Nov 6, 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-mediumsource/agenttype/testvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions