File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# ruff: noqa: E402
22"""Tests for the bookings example."""
33
4- import importlib
54import sys
65from pathlib import Path
76
1413if example_path_str not in sys .path :
1514 sys .path .insert (0 , example_path_str )
1615
17- # Import app - reload to avoid caching issues
18- if "main" in sys .modules :
19- importlib .reload (sys .modules ["main" ])
20- from main import app # noqa: E402
21-
2216CPO_BASE_URL = "/ocpi/cpo/2.3.0/bookings"
2317# Base64-encoded token for OCPI 2.3.0 (my-cpo-token-123)
2418AUTH_HEADER = {"Authorization" : "Token bXktY3BvLXRva2VuLTEyMw==" }
2519
2620
27- @pytest .fixture
21+ @pytest .fixture ( scope = "function" )
2822def client ():
29- """Create test client."""
30- # Clear storage between tests
31- # Reload crud module to ensure fresh state
32- if "crud" in sys .modules :
33- importlib .reload (sys .modules ["crud" ])
23+ """Create test client with isolated storage."""
24+ # Import here to avoid module-level import issues
25+ import main # noqa: E402
3426 import crud # noqa: E402
3527
28+ # Clear storage before each test
3629 crud .bookings_storage .clear ()
37- return TestClient (app )
30+ return TestClient (main . app )
3831
3932
4033@pytest .fixture
You can’t perform that action at this time.
0 commit comments