(self)
| 42 | self._client2: CopilotClient | None = None |
| 43 | |
| 44 | async def setup(self): |
| 45 | self.cli_path = get_cli_path_for_tests() |
| 46 | self.home_dir = os.path.realpath(tempfile.mkdtemp(prefix="copilot-cmd-config-")) |
| 47 | self.work_dir = os.path.realpath(tempfile.mkdtemp(prefix="copilot-cmd-work-")) |
| 48 | |
| 49 | self._proxy = CapiProxy() |
| 50 | self.proxy_url = await self._proxy.start() |
| 51 | |
| 52 | github_token = ( |
| 53 | "fake-token-for-e2e-tests" if os.environ.get("GITHUB_ACTIONS") == "true" else None |
| 54 | ) |
| 55 | |
| 56 | # Client 1 uses TCP mode so a second client can connect |
| 57 | self._client1 = CopilotClient( |
| 58 | connection=RuntimeConnection.for_tcp( |
| 59 | path=self.cli_path, connection_token="py-tcp-shared-test-token" |
| 60 | ), |
| 61 | working_directory=self.work_dir, |
| 62 | env=self._get_env(), |
| 63 | github_token=github_token, |
| 64 | ) |
| 65 | |
| 66 | # Trigger connection to get the port |
| 67 | init_session = await self._client1.create_session( |
| 68 | on_permission_request=PermissionHandler.approve_all, |
| 69 | ) |
| 70 | await init_session.disconnect() |
| 71 | |
| 72 | actual_port = self._client1.runtime_port |
| 73 | assert actual_port is not None |
| 74 | |
| 75 | self._client2 = CopilotClient( |
| 76 | connection=RuntimeConnection.for_uri( |
| 77 | f"localhost:{actual_port}", connection_token="py-tcp-shared-test-token" |
| 78 | ) |
| 79 | ) |
| 80 | |
| 81 | async def teardown(self, test_failed: bool = False): |
| 82 | for c in (self._client2, self._client1): |
no test coverage detected