Skip to content

Replace Click's deprecated isolated_filesystem in the CLI tests - #68

Merged
haruotsu merged 2 commits into
mainfrom
replace-deprecated-isolated-filesystem
Sep 10, 2026
Merged

Replace Click's deprecated isolated_filesystem in the CLI tests#68
haruotsu merged 2 commits into
mainfrom
replace-deprecated-isolated-filesystem

Conversation

@haruotsu

Copy link
Copy Markdown
Collaborator

Click 8.5.0 deprecates CliRunner.isolated_filesystem and removes it in 9.0. The CLI tests used it in 19 places, so on 8.5.0 the suite still passes but emits 23 DeprecationWarnings, and on 9.0 it stops working. This replaces it before that becomes urgent.

What changes

The commands fall into two groups, and the replacement differs for each.

archive needs no working directory at all. It takes the agent directory as an argument and finds the project by walking up from that, so its tests now pass absolute paths and do not move anywhere. test_plain_mode_still_requires_the_directory loses its project fixture with it, since nothing in that test needs a project on disk any more.

validate, terraform, register, init, connections and graph read the project from the working directory by design. Their tests still have to run from inside a tree, so monkeypatch.chdir moves there and pytest restores it afterwards. Two fixtures carry the distinction the old calls made through their arguments:

  • below_project — a directory under the project root, for the walk up to gete.yaml.
  • outside_any_project — a directory with nothing above it, for the commands that have to answer before a project exists.

outside_any_project also asserts that no gete.yaml sits above the temporary directory. Without that, a stray one would make every "there is no project" test pass without proving anything.

Verification

  • ruff check, ruff format --check, mypy and the full suite pass; the collected test count is unchanged at 878.
  • Run against click==8.5.0: 878 passed, and the 23 deprecation warnings are gone.
  • Both fixtures were checked for load: removing the chdir from below_project fails 12 tests, and removing it from outside_any_project fails 2. Neither fixture is decoration.

What this does not do

The remaining chdir calls could be removed only by giving the CLI a way to name the project explicitly, such as a --project or -C option. That is a change to the command's interface rather than to its tests, so it is left out here.

Click 8.5.0 deprecates CliRunner.isolated_filesystem and removes it in 9.0,
so every CLI test that used it would break on that upgrade.

The commands fall into two groups. archive takes the agent directory as an
argument and finds the project by walking up from it, so its tests need no
working directory at all and now pass absolute paths only. validate,
terraform, register, init, connections and graph read the project from the
working directory by design, so their tests still have to run from inside a
tree; monkeypatch.chdir moves there and pytest puts it back.

Two fixtures carry the distinction the old calls made through their
arguments: below_project for the walk up to gete.yaml, outside_any_project
for the commands that have to answer before a project exists. The second
asserts that no gete.yaml sits above the temporary directory, because one
that did would let those tests pass without proving anything.

🤖 Generated with Claude Code
@haruotsu
haruotsu merged commit 44ea86b into main Sep 10, 2026
3 checks passed
@haruotsu
haruotsu deleted the replace-deprecated-isolated-filesystem branch September 10, 2026 01:31
@github-actions github-actions Bot mentioned this pull request Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant