"""Both CLIs must refuse to run inside the Claude sandbox.""" from __future__ import annotations import pytest from git_maintainer_tools import setup_remotes, sign_push @pytest.mark.parametrize( "module,env", [ (setup_remotes, "CLAUDE_CODE"), (setup_remotes, "CLAUDECODE"), (sign_push, "CLAUDE_CODE"), (sign_push, "CLAUDECODE"), ], ) def test_refuses_in_sandbox(monkeypatch, capsys, module, env): monkeypatch.setenv(env, "1") with pytest.raises(SystemExit) as exc: module.main([]) assert exc.value.code == 1 err = capsys.readouterr().err assert "must run outside the Claude sandbox" in err def test_setup_remotes_missing_canonical(monkeypatch, capsys): monkeypatch.delenv("CLAUDE_CODE", raising=False) monkeypatch.delenv("CLAUDECODE", raising=False) monkeypatch.delenv("CANONICAL_URL", raising=False) # Guard against any ambient FORK_URL that would let the CLI get past # the canonical check before hitting the canonical error path. monkeypatch.delenv("FORK_URL", raising=False) rc = setup_remotes.main([]) assert rc == 1 assert "missing canonical URL" in capsys.readouterr().err