Return environment variables configured for isolated testing.
(self)
| 147 | item.unlink(missing_ok=True) |
| 148 | |
| 149 | def get_env(self) -> dict: |
| 150 | """Return environment variables configured for isolated testing.""" |
| 151 | env = os.environ.copy() |
| 152 | if self._proxy: |
| 153 | env.update(self._proxy.get_proxy_env()) |
| 154 | |
| 155 | env.update( |
| 156 | { |
| 157 | "COPILOT_API_URL": self.proxy_url, |
| 158 | # Route GitHub API calls (e.g. the MCP registry policy check) to |
| 159 | # the replay proxy so MCP enablement stays hermetic. Without this |
| 160 | # the CLI reaches the real api.github.com, which is slow/unreachable |
| 161 | # on macOS CI runners and makes MCP servers time out before |
| 162 | # reaching connected. |
| 163 | "COPILOT_DEBUG_GITHUB_API_URL": self.proxy_url, |
| 164 | "COPILOT_HOME": self.home_dir, |
| 165 | "COPILOT_SDK_AUTH_TOKEN": DEFAULT_GITHUB_TOKEN, |
| 166 | "GH_CONFIG_DIR": self.home_dir, |
| 167 | "GH_TOKEN": DEFAULT_GITHUB_TOKEN, |
| 168 | "XDG_CONFIG_HOME": self.home_dir, |
| 169 | "XDG_STATE_HOME": self.home_dir, |
| 170 | "GITHUB_TOKEN": DEFAULT_GITHUB_TOKEN, |
| 171 | "COPILOT_MCP_APPS": "true", |
| 172 | "MCP_APPS": "true", |
| 173 | } |
| 174 | ) |
| 175 | return env |
| 176 | |
| 177 | @property |
| 178 | def client(self) -> CopilotClient: |