From a8c457dea36e30abf3f503b3bd780d30da8fc6dd Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Wed, 11 Feb 2026 12:07:28 -0800 Subject: [PATCH 1/3] refactor(python): move tests into python/tests/ directory Relocate all Python unit and E2E test files from python/ and python/e2e/ into python/tests/ and python/tests/e2e/ for better project organization. Update pyproject.toml test paths accordingly. --- python/pyproject.toml | 2 +- python/{ => tests}/e2e/__init__.py | 0 python/{ => tests}/e2e/conftest.py | 0 python/{ => tests}/e2e/test_ask_user.py | 0 python/{ => tests}/e2e/test_client.py | 0 python/{ => tests}/e2e/test_compaction.py | 0 python/{ => tests}/e2e/test_hooks.py | 0 python/{ => tests}/e2e/test_mcp_and_agents.py | 0 python/{ => tests}/e2e/test_permissions.py | 0 python/{ => tests}/e2e/test_session.py | 0 python/{ => tests}/e2e/test_skills.py | 0 python/{ => tests}/e2e/test_tools.py | 0 python/{ => tests}/e2e/test_tools_unit.py | 0 python/{ => tests}/e2e/testharness/__init__.py | 0 python/{ => tests}/e2e/testharness/context.py | 0 python/{ => tests}/e2e/testharness/helper.py | 0 python/{ => tests}/e2e/testharness/proxy.py | 0 python/{ => tests}/test_client.py | 0 python/{ => tests}/test_event_forward_compatibility.py | 0 python/{ => tests}/test_jsonrpc.py | 0 20 files changed, 1 insertion(+), 1 deletion(-) rename python/{ => tests}/e2e/__init__.py (100%) rename python/{ => tests}/e2e/conftest.py (100%) rename python/{ => tests}/e2e/test_ask_user.py (100%) rename python/{ => tests}/e2e/test_client.py (100%) rename python/{ => tests}/e2e/test_compaction.py (100%) rename python/{ => tests}/e2e/test_hooks.py (100%) rename python/{ => tests}/e2e/test_mcp_and_agents.py (100%) rename python/{ => tests}/e2e/test_permissions.py (100%) rename python/{ => tests}/e2e/test_session.py (100%) rename python/{ => tests}/e2e/test_skills.py (100%) rename python/{ => tests}/e2e/test_tools.py (100%) rename python/{ => tests}/e2e/test_tools_unit.py (100%) rename python/{ => tests}/e2e/testharness/__init__.py (100%) rename python/{ => tests}/e2e/testharness/context.py (100%) rename python/{ => tests}/e2e/testharness/helper.py (100%) rename python/{ => tests}/e2e/testharness/proxy.py (100%) rename python/{ => tests}/test_client.py (100%) rename python/{ => tests}/test_event_forward_compatibility.py (100%) rename python/{ => tests}/test_jsonrpc.py (100%) diff --git a/python/pyproject.toml b/python/pyproject.toml index b902b050..0ec35a44 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -81,7 +81,7 @@ exclude = [ ] [tool.pytest.ini_options] -testpaths = ["."] +testpaths = ["tests"] python_files = "test_*.py" python_classes = "Test*" python_functions = "test_*" diff --git a/python/e2e/__init__.py b/python/tests/e2e/__init__.py similarity index 100% rename from python/e2e/__init__.py rename to python/tests/e2e/__init__.py diff --git a/python/e2e/conftest.py b/python/tests/e2e/conftest.py similarity index 100% rename from python/e2e/conftest.py rename to python/tests/e2e/conftest.py diff --git a/python/e2e/test_ask_user.py b/python/tests/e2e/test_ask_user.py similarity index 100% rename from python/e2e/test_ask_user.py rename to python/tests/e2e/test_ask_user.py diff --git a/python/e2e/test_client.py b/python/tests/e2e/test_client.py similarity index 100% rename from python/e2e/test_client.py rename to python/tests/e2e/test_client.py diff --git a/python/e2e/test_compaction.py b/python/tests/e2e/test_compaction.py similarity index 100% rename from python/e2e/test_compaction.py rename to python/tests/e2e/test_compaction.py diff --git a/python/e2e/test_hooks.py b/python/tests/e2e/test_hooks.py similarity index 100% rename from python/e2e/test_hooks.py rename to python/tests/e2e/test_hooks.py diff --git a/python/e2e/test_mcp_and_agents.py b/python/tests/e2e/test_mcp_and_agents.py similarity index 100% rename from python/e2e/test_mcp_and_agents.py rename to python/tests/e2e/test_mcp_and_agents.py diff --git a/python/e2e/test_permissions.py b/python/tests/e2e/test_permissions.py similarity index 100% rename from python/e2e/test_permissions.py rename to python/tests/e2e/test_permissions.py diff --git a/python/e2e/test_session.py b/python/tests/e2e/test_session.py similarity index 100% rename from python/e2e/test_session.py rename to python/tests/e2e/test_session.py diff --git a/python/e2e/test_skills.py b/python/tests/e2e/test_skills.py similarity index 100% rename from python/e2e/test_skills.py rename to python/tests/e2e/test_skills.py diff --git a/python/e2e/test_tools.py b/python/tests/e2e/test_tools.py similarity index 100% rename from python/e2e/test_tools.py rename to python/tests/e2e/test_tools.py diff --git a/python/e2e/test_tools_unit.py b/python/tests/e2e/test_tools_unit.py similarity index 100% rename from python/e2e/test_tools_unit.py rename to python/tests/e2e/test_tools_unit.py diff --git a/python/e2e/testharness/__init__.py b/python/tests/e2e/testharness/__init__.py similarity index 100% rename from python/e2e/testharness/__init__.py rename to python/tests/e2e/testharness/__init__.py diff --git a/python/e2e/testharness/context.py b/python/tests/e2e/testharness/context.py similarity index 100% rename from python/e2e/testharness/context.py rename to python/tests/e2e/testharness/context.py diff --git a/python/e2e/testharness/helper.py b/python/tests/e2e/testharness/helper.py similarity index 100% rename from python/e2e/testharness/helper.py rename to python/tests/e2e/testharness/helper.py diff --git a/python/e2e/testharness/proxy.py b/python/tests/e2e/testharness/proxy.py similarity index 100% rename from python/e2e/testharness/proxy.py rename to python/tests/e2e/testharness/proxy.py diff --git a/python/test_client.py b/python/tests/test_client.py similarity index 100% rename from python/test_client.py rename to python/tests/test_client.py diff --git a/python/test_event_forward_compatibility.py b/python/tests/test_event_forward_compatibility.py similarity index 100% rename from python/test_event_forward_compatibility.py rename to python/tests/test_event_forward_compatibility.py diff --git a/python/test_jsonrpc.py b/python/tests/test_jsonrpc.py similarity index 100% rename from python/test_jsonrpc.py rename to python/tests/test_jsonrpc.py From 5c64e4127a22d71ec252a361ef2b0adcefe1ed29 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Wed, 11 Feb 2026 13:41:24 -0800 Subject: [PATCH 2/3] Fix some lingering path issues --- python/tests/e2e/testharness/context.py | 8 +++----- python/tests/e2e/testharness/proxy.py | 6 +++++- python/tests/{e2e => }/test_tools_unit.py | 0 3 files changed, 8 insertions(+), 6 deletions(-) rename python/tests/{e2e => }/test_tools_unit.py (100%) diff --git a/python/tests/e2e/testharness/context.py b/python/tests/e2e/testharness/context.py index 533ee87e..ca87ec20 100644 --- a/python/tests/e2e/testharness/context.py +++ b/python/tests/e2e/testharness/context.py @@ -13,14 +13,12 @@ from copilot import CopilotClient -from .proxy import CapiProxy - +from .proxy import BASE_DIR, CapiProxy def get_cli_path_for_tests() -> str: """Get CLI path for E2E tests. Uses node_modules CLI during development.""" # Look for CLI in sibling nodejs directory's node_modules - base_path = Path(__file__).parents[3] - full_path = base_path / "nodejs" / "node_modules" / "@github" / "copilot" / "index.js" + full_path = BASE_DIR / "nodejs" / "node_modules" / "@github" / "copilot" / "index.js" if full_path.exists(): return str(full_path.resolve()) @@ -28,7 +26,7 @@ def get_cli_path_for_tests() -> str: CLI_PATH = get_cli_path_for_tests() -SNAPSHOTS_DIR = Path(__file__).parents[3] / "test" / "snapshots" +SNAPSHOTS_DIR = BASE_DIR / "test" / "snapshots" class E2ETestContext: diff --git a/python/tests/e2e/testharness/proxy.py b/python/tests/e2e/testharness/proxy.py index e26ec65c..8271e0f6 100644 --- a/python/tests/e2e/testharness/proxy.py +++ b/python/tests/e2e/testharness/proxy.py @@ -6,6 +6,7 @@ """ import os +import pathlib import platform import re import subprocess @@ -14,6 +15,9 @@ import httpx +BASE_DIR = pathlib.Path(__file__).parents[4] + + class CapiProxy: """Manages a replaying proxy server for E2E tests.""" @@ -28,7 +32,7 @@ async def start(self) -> str: # The harness server is in the shared test directory server_path = os.path.join( - os.path.dirname(__file__), "..", "..", "..", "test", "harness", "server.ts" + BASE_DIR / "test" / "harness" / "server.ts" ) server_path = os.path.abspath(server_path) diff --git a/python/tests/e2e/test_tools_unit.py b/python/tests/test_tools_unit.py similarity index 100% rename from python/tests/e2e/test_tools_unit.py rename to python/tests/test_tools_unit.py From fda61b753e86b1c5c6d19ff077d0c2e42ad34756 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Wed, 11 Feb 2026 13:49:35 -0800 Subject: [PATCH 3/3] Fix formatting --- python/tests/e2e/testharness/context.py | 1 + python/tests/e2e/testharness/proxy.py | 5 +---- python/tests/test_client.py | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/python/tests/e2e/testharness/context.py b/python/tests/e2e/testharness/context.py index ca87ec20..fb084a80 100644 --- a/python/tests/e2e/testharness/context.py +++ b/python/tests/e2e/testharness/context.py @@ -15,6 +15,7 @@ from .proxy import BASE_DIR, CapiProxy + def get_cli_path_for_tests() -> str: """Get CLI path for E2E tests. Uses node_modules CLI during development.""" # Look for CLI in sibling nodejs directory's node_modules diff --git a/python/tests/e2e/testharness/proxy.py b/python/tests/e2e/testharness/proxy.py index 8271e0f6..21ca6b96 100644 --- a/python/tests/e2e/testharness/proxy.py +++ b/python/tests/e2e/testharness/proxy.py @@ -14,7 +14,6 @@ import httpx - BASE_DIR = pathlib.Path(__file__).parents[4] @@ -31,9 +30,7 @@ async def start(self) -> str: return self._proxy_url # The harness server is in the shared test directory - server_path = os.path.join( - BASE_DIR / "test" / "harness" / "server.ts" - ) + server_path = os.path.join(BASE_DIR / "test" / "harness" / "server.ts") server_path = os.path.abspath(server_path) # On Windows, use shell=True to find npx diff --git a/python/tests/test_client.py b/python/tests/test_client.py index 7b4af8c0..114fe794 100644 --- a/python/tests/test_client.py +++ b/python/tests/test_client.py @@ -5,9 +5,9 @@ """ import pytest +from e2e.testharness import CLI_PATH from copilot import CopilotClient -from e2e.testharness import CLI_PATH class TestHandleToolCallRequest: