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/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 95% rename from python/e2e/testharness/context.py rename to python/tests/e2e/testharness/context.py index 533ee87e..fb084a80 100644 --- a/python/e2e/testharness/context.py +++ b/python/tests/e2e/testharness/context.py @@ -13,14 +13,13 @@ 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 +27,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/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 96% rename from python/e2e/testharness/proxy.py rename to python/tests/e2e/testharness/proxy.py index e26ec65c..21ca6b96 100644 --- a/python/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 @@ -13,6 +14,8 @@ import httpx +BASE_DIR = pathlib.Path(__file__).parents[4] + class CapiProxy: """Manages a replaying proxy server for E2E tests.""" @@ -27,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( - os.path.dirname(__file__), "..", "..", "..", "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/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 index 7b4af8c0..114fe794 100644 --- a/python/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: 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 diff --git a/python/e2e/test_tools_unit.py b/python/tests/test_tools_unit.py similarity index 100% rename from python/e2e/test_tools_unit.py rename to python/tests/test_tools_unit.py