-
Notifications
You must be signed in to change notification settings - Fork 37
/
conftest.py
53 lines (40 loc) · 1.28 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import asyncio
import inspect
from pathlib import Path
import pytest
collect_ignore = [
"hishel",
]
@pytest.fixture(scope="session")
def load_dotenv():
import dotenv
dotenv.load_dotenv()
def path_generator_function(function):
func_path = inspect.getfile(function)
func_path = func_path.replace("_async/", "")
func_path = func_path.replace("_sync/", "")
return str(Path(func_path) / function.__name__)
@pytest.fixture(scope="module")
def vcr_config():
return {
# Replace the Authorization request header with "REDACTED" in cassettes
"filter_headers": [("Authorization", "REDACTED"), ("X-API-KEY", "REDACTED")],
# "serializer": "json",
# "path_transformer": VCR.ensure_suffix(".json"),
"record_mode": "new_episodes",
"record_on_exception": False,
"func_path_generator": path_generator_function,
}
def pytest_collection_modifyitems(items):
for item in items:
if not item.get_closest_marker("no_vcr"):
item.add_marker(pytest.mark.vcr)
# item.add_marker(pytest.mark.block_network)
@pytest.fixture(scope="session")
def event_loop():
try:
loop = asyncio.get_running_loop()
except RuntimeError:
loop = asyncio.new_event_loop()
yield loop
loop.close()