Skip to content

fix(tests): a devcontainer dry-run test reads the tools of the host #3025

Closed

Description

@dan-petty

What happened

tests/commands/test_devcontainer_install_tools_dry_run.py::test_mark_only_commands_under_global_dry_run fails on a workstation where the devcontainer CLI is installed in ~/.local/bin. The test expects the text not installed in the output of devops tools status. The real host answers 0.89.0 and a path.

It passes on a clean GitHub runner. This is the same class as #2165: a test reads the tools of the host instead of a fake.

What should happen

The test sets the tool probe to a fake, so the result does not depend on the tools of the host.

Acceptance criteria

  • The test passes on a host that has the devcontainer CLI installed.
  • The test passes on a host that has no devcontainer CLI.

Alternatives check of 2026-11-04: covers.
Tool: pytest-dev/pytest (https://github.com/pytest-dev/pytest), MIT, last activity 2026-11-04, maintained.

Proposed design

Problem statement

Two tests read the tools of the host and not a fake. They fail on a host that has tools in its home directory, and they make a full devops ci fail there. The first is test_mark_only_commands_under_global_dry_run, which expects not installed from install-tools status. The code at the refined commit already holds its fix (#3871). The second is test_the_direct_executor_refuses_a_network_profile_before_it_starts_the_tool[direct] in tests/ai/test_tool_executor_contract.py. It reaches the host path ~/.local/share/devops-cli/tools/popeye and then the network edge without a fake.

Acceptance criteria

Requirement: Status test ignores host tools

The install-tools status dry-run test SHALL run with an empty target directory and an empty PATH, so the result does not depend on the tools of the host.

Scenario: Host has the devcontainer CLI installed

  • WHEN the test runs on a host that has the devcontainer CLI in ~/.local/bin
  • THEN the exit code is 0 and the output holds not installed

Requirement: Status test passes on a clean host

The install-tools status dry-run test MUST pass on a host that has no devcontainer CLI.

Scenario: Host has no devcontainer CLI

  • WHEN the test runs on a clean runner
  • THEN the exit code is 0 and the output holds not installed

Requirement: At pin row is checked with a link

A test SHALL link the devcontainers-cli tool at its pin under a temporary directory and SHALL check the row of the tool before and after the link.

Scenario: Tool linked at its pin

  • WHEN the test reads the status row before and after link_at_pin runs
  • THEN the row shows not installed before the link and at pin after it

Requirement: Executor test uses a fake tool path

The test that the direct executor refuses a network profile SHALL replace the host tool path and the network edge with fakes, so it never reads the home directory of the host.

Scenario: Tools installed in the home directory

  • WHEN the test runs on a host that has popeye under ~/.local/share/devops-cli/tools
  • THEN the executor refuses the network profile before it starts the tool, and no host path or network edge is reached

Existing Tool Considered

pytest (https://github.com/pytest-dev/pytest, MIT, maintained) covers the need. Its monkeypatch and tmp_path fixtures isolate PATH, the target directory and the tool probe, and pytest restores each value after the test. It has no built-in fake of the tool probe, so each test sets its own fake. The project already uses pytest, so no new code or dependency is built. The change edits two test modules only.

Key questions

  • Adopt pytest, which the alternatives check found to cover this item, or keep the item and give a reason?: Adopt pytest. It is the test framework of the project. The fix uses its monkeypatch.setenv and tmp_path fixtures, with no new dependency and no change to production code. (best practice) [sources: tests/commands/test_devcontainer_install_tools_dry_run.py]
    • Chosen: Adopt pytest monkeypatch and tmp_path. The project already uses pytest. It isolates the host without new code.
    • Rejected: Add a new library to fake the tool probe. It adds a dependency and gives no gain over monkeypatch.
    • Rejected: Change production code to inject the probe. The issue limits the change to tests, and monkeypatch is enough.
  • Why does the status test show host tools?: install-tools status searches its target directory, which defaults to ~/.local/bin, before PATH. A host with the devcontainer CLI there shows a version and a path, not not installed. [sources: tests/commands/test_devcontainer_install_tools_dry_run.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    scope/tests
    status/new
    value/medium
    effort/low
    on Nov 1, 2026
  2. dan-petty commented on Nov 1, 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/bug. The fix prefix of the title gives the type.
    • Scope: scope/tests. The (tests) scope of the title gives the scope.
    • Priority: P3-Low. The test passes on CI runners and only fails on workstations where the devcontainer CLI is installed.
    • Value: Medium. It breaks the test suite for developers whose workstation has the devcontainer CLI.
    • Effort: Low. The fix is to set one tool probe to a fake in a single test function.
    • Related: test(floor): every test sees the same tokenizer cache, mounts, process table, PATH and programs on every host, and no skip depends on the host #2165, which asks for a different change. Both address tests that read host state instead of fakes, but #2165 is the umbrella floor and the candidate fixes one specific devcontainer dry-run test.
  3. added
    priority/p3-low
    on Nov 1, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 2, 2026
  5. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

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

  6. devops-cli-service commented on Nov 3, 2026

    @devops-cli-service
    Contributor

    The stage job returned the item to New. The premise of the issue does not hold at the staging commit, so the job planned no change and opened no pull request.

    Evidence:

    placeholder

  7. added
    status/new
    and removed
    status/ready
    on Nov 3, 2026
  8. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Alternatives check: covers

    Tool: pytest-dev/pytest (https://github.com/pytest-dev/pytest)

    • License: MIT
    • Last activity: 2026-11-04
    • Maintained: yes

    Covers:

    • pytest's monkeypatch fixture replaces an attribute with monkeypatch.setattr, so the test can swap the install-tools tool probe for a fake before invoking the command, and pytest restores the original afterwards.
    • Because the patched callable is fully replaced, the fake can raise an error to prove the real probe is never called, satisfying the no-real-probe requirement.
    • The patch is scoped to the single test, so the test can assert exit code 0 and the text 'not installed' regardless of whether the host has the devcontainer CLI.
    • It needs no production-code change: only the test module changes, which matches the issue's constraint.

    Lacks:

    • No built-in fake for the devops install-tools tool-status probe; the test itself must define the fake probe and decide which function to patch (the narrowest probe in devops_cli.commands.install_tools).
    • It does not automatically find host reads for you; the author must still identify the probe function, so other host-dependent tests are not fixed by it.

    Searches run:

    • pytest monkeypatch fixture replace function in test
    • pytest-mock mocker.patch fixture library

    Sources:

    Checked on 2026-11-04. A person decides what this means for the item. The check changes no label and closes no issue.

  9. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 46cf288 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • The alternatives check found that https://github.com/pytest-dev/pytest covers this item. Adopt the tool, or keep the item and give the reason. (a person decides)
  10. dan-petty commented on Nov 4, 2026

    @dan-petty
    OwnerAuthor

    A second test has the same cause. On origin/main at 46cf288, in the devcontainer, these two tests fail when the tools are installed in the home directory of the host:

    • tests/commands/test_devcontainer_install_tools_dry_run.py::test_mark_only_commands_under_global_dry_run: 'not installed' is not in the output.
    • tests/ai/test_tool_executor_contract.py::test_the_direct_executor_refuses_a_network_profile_before_it_starts_the_tool[direct]: host path reached without a fake: ~/.local/share/devops-cli/tools/popeye, and then network edge reached without a fake.

    They make a full devops ci fail in that environment for each branch.

  11. dan-petty commented on Nov 7, 2026

    @dan-petty
    OwnerAuthor

    Pull request #3871 covers both criteria of this issue. The install-tools status test now runs with an empty target directory and an empty PATH, because status searches its target directory (default ~/.local/bin) before PATH. It passes on this host, which has the devcontainer CLI installed. A second test links the tool at its pin under a temporary directory and shows at pin, and shows not installed before the link. The pull request does not close this issue: a person closes it after the merge.

  12. added
    status/ready
    and removed
    status/new
    on Nov 9, 2026
  13. devops-cli-service commented on Nov 9, 2026

    @devops-cli-service
    Contributor

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

  14. dan-petty commented on Nov 10, 2026

    @dan-petty
    OwnerAuthor

    #3871 delivered both criteria of this issue, and f600ed49 is on main.

    Verified on a host that has both tools that the issue names:

    • ~/.local/bin/devcontainer is version 0.89.0.
    • ~/.local/share/devops-cli/tools/popeye exists.
    • uv run pytest tests/commands/test_devcontainer_install_tools_dry_run.py tests/ai/test_tool_executor_contract.py passes 101 tests.

    The status test uses an empty target directory and an empty PATH. The at-pin test reads the row before and after link_at_pin. The direct-executor case puts a Popeye stand-in first on PATH, so no tool of the host is resolved.

  15. removed
    status/ready
    on Nov 10, 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/lowpriority/p3-lowscope/testssource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions