style: format with black and fix ruff SIM117 warnings
- Merge nested with statements in test_project_root.py - Reformat multi-line calls in test_cli.py and update.py
This commit is contained in:
@@ -43,7 +43,9 @@ def update_cmd() -> None:
|
||||
if makefile.is_file():
|
||||
rc = _run_make_install(root)
|
||||
if rc != 0:
|
||||
console.print("[yellow]make install failed, trying pip -e…[/yellow]")
|
||||
console.print(
|
||||
"[yellow]make install failed, trying pip -e…[/yellow]"
|
||||
)
|
||||
rc = _run_pip_editable(root)
|
||||
else:
|
||||
rc = _run_pip_editable(root)
|
||||
|
||||
+4
-2
@@ -31,7 +31,10 @@ class TestCliHelp:
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(cli, ["update", "--help"])
|
||||
assert result.exit_code == 0
|
||||
assert "update" in result.output.lower() or "reinstall" in result.output.lower()
|
||||
assert (
|
||||
"update" in result.output.lower()
|
||||
or "reinstall" in result.output.lower()
|
||||
)
|
||||
|
||||
def test_upgrade_alias_exists(self) -> None:
|
||||
"""upgrade should be an alias for update."""
|
||||
@@ -96,4 +99,3 @@ class TestCliDefaultBehavior:
|
||||
assert result.exit_code == 0
|
||||
call_args = mock_run.call_args[0][0]
|
||||
assert "--dangerously-skip-permissions" in call_args
|
||||
|
||||
|
||||
+19
-12
@@ -22,9 +22,14 @@ class TestGetMyclaudeProjectRoot:
|
||||
|
||||
def test_fallback_when_not_in_repo(self) -> None:
|
||||
"""When not in a repo, fallback to ~/.myclaude."""
|
||||
with patch.dict(os.environ, {}, clear=True):
|
||||
with patch("pathlib.Path.cwd", side_effect=OSError):
|
||||
with patch("bin.project_root._pyproject_names_myclaude", return_value=False):
|
||||
with (
|
||||
patch.dict(os.environ, {}, clear=True),
|
||||
patch("pathlib.Path.cwd", side_effect=OSError),
|
||||
patch(
|
||||
"bin.project_root._pyproject_names_myclaude",
|
||||
return_value=False,
|
||||
),
|
||||
):
|
||||
result = get_myclaude_project_root()
|
||||
assert result == Path.home() / ".myclaude"
|
||||
|
||||
@@ -59,22 +64,24 @@ class TestGetWorkspaceRoot:
|
||||
workspace.mkdir()
|
||||
(project_root / "pyproject.toml").write_text('name = "myclaude"\n')
|
||||
|
||||
with patch.dict(os.environ, {"MYCLAUDE_PROJECT_ROOT": str(project_root)}, clear=True):
|
||||
with patch.dict(
|
||||
os.environ, {"MYCLAUDE_PROJECT_ROOT": str(project_root)}, clear=True
|
||||
):
|
||||
result = get_workspace_root()
|
||||
assert result == workspace.resolve()
|
||||
|
||||
def test_defaults_to_home_workspace(self, tmp_path: Path) -> None:
|
||||
"""When no env var and no project workspace, default to ~/workspace."""
|
||||
with (
|
||||
patch.dict(os.environ, {}, clear=True),
|
||||
patch("bin.project_root.get_myclaude_project_root", return_value=tmp_path / ".myclaude"),
|
||||
patch.dict(os.environ, {}, clear=True),
|
||||
):
|
||||
with patch.dict(os.environ, {}, clear=True):
|
||||
# Ensure HOME is set for Path.home()
|
||||
home = tmp_path / "home"
|
||||
home.mkdir()
|
||||
with patch("pathlib.Path.home", return_value=home):
|
||||
with (
|
||||
patch.dict(os.environ, {}, clear=True),
|
||||
patch(
|
||||
"bin.project_root.get_myclaude_project_root",
|
||||
return_value=tmp_path / ".myclaude",
|
||||
),
|
||||
patch("pathlib.Path.home", return_value=home),
|
||||
):
|
||||
result = get_workspace_root()
|
||||
assert result == home / "workspace"
|
||||
assert result.is_dir()
|
||||
|
||||
Reference in New Issue
Block a user