Skip to content

Commit 644c21f

Browse files
fix(client): mock data loading when imported
1 parent a3ab7df commit 644c21f

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

src/brave_search_python_client/client.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import json
22
import os
3+
import pathlib
34
from typing import Any
45
from urllib.parse import urljoin, urlparse
56

67
import httpx
78
from tenacity import AsyncRetrying, RetryError, stop_after_attempt, wait_fixed
8-
import pathlib
99

1010
from brave_search_python_client.constants import (
1111
BASE_URL,
1212
DEFAULT_RETRY_WAIT_TIME,
1313
MOCK_API_KEY,
14-
MOCK_DATA_PATH,
1514
__version__,
1615
)
1716

@@ -114,12 +113,11 @@ async def _get(
114113

115114
def _load_mock_data(self, search_type: SearchType):
116115
"""Helper method to load mock data for testing purposes."""
117-
import importlib.resources
118-
116+
119117
# Get package root directory
120-
package_root = pathlib.Path(__file__).parent.parent.parent
121-
mock_path = package_root / MOCK_DATA_PATH / f"{search_type}.json"
122-
118+
package_root = pathlib.Path(__file__).parent
119+
mock_path = package_root / f"responses/mock_data/{search_type}.json"
120+
123121
with open(mock_path) as f:
124122
return json.load(f)
125123

0 commit comments

Comments
 (0)