-
Notifications
You must be signed in to change notification settings - Fork 301
/
conftest.py
87 lines (74 loc) · 2.17 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import asyncio
import logging
import os
import pytest
from dotenv import load_dotenv
from hypothesis import Phase, Verbosity, settings
from starkware.cairo.lang.instances import LAYOUTS
load_dotenv()
logging.getLogger("asyncio").setLevel(logging.ERROR)
logger = logging.getLogger()
def pytest_addoption(parser):
parser.addoption(
"--profile-cairo",
action="store_true",
default=False,
help="compute and dump TracerData for the VM runner: True or False",
)
parser.addoption(
"--proof-mode",
action="store_true",
default=False,
help="run the CairoRunner in proof mode: True or False",
)
parser.addoption(
"--layout",
choices=list(LAYOUTS.keys()),
default="starknet_with_keccak",
help="The layout of the Cairo AIR.",
)
parser.addoption(
"--seed",
action="store",
default=None,
type=int,
help="The seed to set random with.",
)
@pytest.fixture(scope="session")
def event_loop():
loop = asyncio.get_event_loop()
yield loop
loop.close()
@pytest.fixture(autouse=True, scope="session")
def seed(request):
if request.config.getoption("seed") is not None:
import random
logger.info(f"Setting seed to {request.config.getoption('seed')}")
random.seed(request.config.getoption("seed"))
pytest_plugins = ["tests.fixtures.starknet"]
settings.register_profile(
"nightly",
deadline=None,
max_examples=1500,
phases=[Phase.explicit, Phase.reuse, Phase.generate, Phase.target],
)
settings.register_profile(
"ci",
deadline=None,
max_examples=100,
phases=[Phase.explicit, Phase.reuse, Phase.generate, Phase.target],
)
settings.register_profile(
"dev",
deadline=None,
max_examples=10,
phases=[Phase.explicit, Phase.reuse, Phase.generate, Phase.target],
)
settings.register_profile(
"debug",
max_examples=10,
verbosity=Verbosity.verbose,
phases=[Phase.explicit, Phase.reuse, Phase.generate, Phase.target],
)
settings.load_profile(os.getenv("HYPOTHESIS_PROFILE", "default"))
logger.info(f"Using Hypothesis profile: {os.getenv('HYPOTHESIS_PROFILE', 'default')}")