fix: resolve E402 linting errors in conftest.py
- Move all imports to top of file including asyncio, tempfile, and pytest - Maintain functionality while following proper import order - All linting checks now pass
This commit is contained in:
@@ -2,10 +2,14 @@
|
|||||||
Pytest configuration for Gemini MCP Server tests
|
Pytest configuration for Gemini MCP Server tests
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import asyncio
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import tempfile
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
# Ensure the parent directory is in the Python path for imports
|
# Ensure the parent directory is in the Python path for imports
|
||||||
parent_dir = Path(__file__).resolve().parent.parent
|
parent_dir = Path(__file__).resolve().parent.parent
|
||||||
if str(parent_dir) not in sys.path:
|
if str(parent_dir) not in sys.path:
|
||||||
@@ -17,23 +21,15 @@ if "GEMINI_API_KEY" not in os.environ:
|
|||||||
|
|
||||||
# Set MCP_PROJECT_ROOT to a temporary directory for tests
|
# Set MCP_PROJECT_ROOT to a temporary directory for tests
|
||||||
# This provides a safe sandbox for file operations during testing
|
# This provides a safe sandbox for file operations during testing
|
||||||
import tempfile
|
|
||||||
|
|
||||||
# Create a temporary directory that will be used as the project root for all tests
|
# Create a temporary directory that will be used as the project root for all tests
|
||||||
test_root = tempfile.mkdtemp(prefix="gemini_mcp_test_")
|
test_root = tempfile.mkdtemp(prefix="gemini_mcp_test_")
|
||||||
os.environ["MCP_PROJECT_ROOT"] = test_root
|
os.environ["MCP_PROJECT_ROOT"] = test_root
|
||||||
|
|
||||||
# Configure asyncio for Windows compatibility
|
# Configure asyncio for Windows compatibility
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
import asyncio
|
|
||||||
|
|
||||||
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
|
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
|
||||||
|
|
||||||
|
|
||||||
# Pytest fixtures
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def project_path(tmp_path):
|
def project_path(tmp_path):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user