forked from fastai/fastai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
30 lines (24 loc) · 888 Bytes
/
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
import pytest
import re
def pytest_addoption(parser):
parser.addoption(
"--runslow", action="store_true", default=False, help="run slow tests"
)
def pytest_collection_modifyitems(config, items):
if config.getoption("--runslow"): return
skip_slow = pytest.mark.skip(reason="need --runslow option to run")
for item in items:
if "slow" in item.keywords: item.add_marker(skip_slow)
"""
def pytest_itemcollected(item):
#import pdb; pdb.set_trace()
par = item.parent.obj
node = item.obj
pref = par.__doc__.strip() if par.__doc__ else par.__class__.__name__
pref = re.sub(r'^Test', '', pref)
if pref=='module': pref = re.sub(r'^test_', '', par.__name__)
suf = node.__doc__.strip() if node.__doc__ else node.__name__
suf = re.sub(r'^test_', '', suf)
suf = ' '.join(suf.split('_'))
item.name = f'{pref}::{suf}'
"""