Add function-scoped auth_client fixture for auth tests
- Add auth_client fixture (function-scoped) for authentication tests - Update all tests in test_auth_api.py to use auth_client - Prevents auth tests from polluting the shared integration_client session - Each auth test gets a fresh client, avoiding state leakage
This commit is contained in:
@@ -249,6 +249,26 @@ def integration_client():
|
||||
yield client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def auth_client():
|
||||
"""
|
||||
Create a function-scoped test client for authentication tests.
|
||||
|
||||
Unlike integration_client (session-scoped), this creates a fresh client
|
||||
for each test. Use this for tests that manipulate authentication state
|
||||
(login, logout, cookie clearing) to avoid polluting other tests.
|
||||
|
||||
Environment variables:
|
||||
ORCHARD_TEST_URL: Base URL of the Orchard server (default: http://localhost:8080)
|
||||
"""
|
||||
import httpx
|
||||
|
||||
base_url = os.environ.get("ORCHARD_TEST_URL", "http://localhost:8080")
|
||||
|
||||
with httpx.Client(base_url=base_url, timeout=30.0) as client:
|
||||
yield client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def unique_test_id():
|
||||
"""Generate a unique ID for test isolation."""
|
||||
|
||||
Reference in New Issue
Block a user