Skip to content

Commit e39a914

Browse files
Copilotpatniko
andcommitted
Address code review feedback: move imports to top and use correct patch paths
Co-authored-by: patniko <26906478+patniko@users.noreply.github.com>
1 parent 45918a6 commit e39a914

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

python/test_client.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
This file is for unit tests. Where relevant, prefer to add e2e tests in e2e/*.py instead.
55
"""
66

7+
from unittest.mock import MagicMock, patch
8+
79
import pytest
810

911
from copilot import CopilotClient
@@ -144,13 +146,11 @@ class TestCLIPathResolution:
144146
@pytest.mark.asyncio
145147
async def test_cli_path_resolved_with_which(self):
146148
"""Test that shutil.which() is used to resolve the CLI path."""
147-
from unittest.mock import MagicMock, patch
148-
149149
# Create a mock resolved path
150150
mock_resolved_path = "/usr/local/bin/copilot"
151151

152-
with patch("shutil.which", return_value=mock_resolved_path):
153-
with patch("subprocess.Popen") as mock_popen:
152+
with patch("copilot.client.shutil.which", return_value=mock_resolved_path):
153+
with patch("copilot.client.subprocess.Popen") as mock_popen:
154154
# Mock the process and its stdout for TCP mode
155155
mock_process = MagicMock()
156156
mock_process.stdout.readline.return_value = b"listening on port 8080\n"
@@ -174,12 +174,10 @@ async def test_cli_path_resolved_with_which(self):
174174
@pytest.mark.asyncio
175175
async def test_cli_path_not_resolved_when_which_returns_none(self):
176176
"""Test that original path is used when shutil.which() returns None."""
177-
from unittest.mock import MagicMock, patch
178-
179177
original_path = "/custom/path/to/copilot"
180178

181-
with patch("shutil.which", return_value=None):
182-
with patch("subprocess.Popen") as mock_popen:
179+
with patch("copilot.client.shutil.which", return_value=None):
180+
with patch("copilot.client.subprocess.Popen") as mock_popen:
183181
# Mock the process and its stdout for TCP mode
184182
mock_process = MagicMock()
185183
mock_process.stdout.readline.return_value = b"listening on port 8080\n"

0 commit comments

Comments
 (0)