forked from python-trio/flake8-async
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
35 lines (26 loc) · 1 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
from __future__ import annotations
import pytest
def pytest_addoption(parser: pytest.Parser):
parser.addoption(
"--runfuzz", action="store_true", default=False, help="run fuzz tests"
)
parser.addoption(
"--enable-visitor-codes-regex",
default=".*",
help="select error codes whose visitors to run.",
)
def pytest_configure(config: pytest.Config):
config.addinivalue_line(
"markers", "fuzz: mark test as a slow fuzzer to not run by default"
)
def pytest_collection_modifyitems(config: pytest.Config, items: list[pytest.Item]):
if config.getoption("--runfuzz"):
# --runfuzz given in cli: do not skip fuzz tests
return
skip_fuzz = pytest.mark.skip(reason="need --runfuzz option to run")
for item in items:
if "fuzz" in item.keywords:
item.add_marker(skip_fuzz)
@pytest.fixture
def enable_visitor_codes_regex(request: pytest.FixtureRequest):
return request.config.getoption("--enable-visitor-codes-regex")