Skip to content

Commit 68da1ae

Browse files
Clean up test imports per Copilot suggestion
Remove module-level sys.path manipulation from test files: - test_browsergym_models.py: removed entirely (pytest handles imports) - test_browsergym_environment.py: moved into server fixture where it's actually needed for subprocess environment This is cleaner and follows pytest best practices.
1 parent 86c26ce commit 68da1ae

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

tests/envs/test_browsergym_environment.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,16 @@
77
import requests
88
import pytest
99

10-
# Add src to path
11-
ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
12-
SRC_PATH = os.path.join(ROOT_DIR, "src")
13-
sys.path.insert(0, SRC_PATH)
14-
1510
from envs.browsergym_env.client import BrowserGymEnv
1611
from envs.browsergym_env.models import BrowserGymAction
1712

1813

1914
@pytest.fixture(scope="module")
2015
def server():
2116
"""Starts the BrowserGym environment server as a background process."""
17+
# Define paths for subprocess environment
18+
ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
19+
SRC_PATH = os.path.join(ROOT_DIR, "src")
2220
PORT = 8010
2321
localhost = f"http://localhost:{PORT}"
2422

tests/envs/test_browsergym_models.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
"""Unit tests for BrowserGym models."""
22

3-
import os
4-
import sys
5-
6-
73
from envs.browsergym_env.models import (
84
BrowserGymAction,
95
BrowserGymObservation,

0 commit comments

Comments
 (0)