-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathconftest.py
More file actions
20 lines (17 loc) · 815 Bytes
/
conftest.py
File metadata and controls
20 lines (17 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"""Pytest configuration for pynumdiff tests"""
import pytest
from matplotlib import pyplot
from collections import defaultdict
def pytest_addoption(parser):
parser.addoption("--plot", action="store_true", default=False) # whether to show plots
parser.addoption("--bounds", action="store_true", default=False) # whether to print error bounds
@pytest.fixture(scope="session", autouse=True)
def store_plots(request):
request.config.plots = defaultdict(lambda: pyplot.subplots(6, 2, figsize=(12,7))) # 6 is len(test_funcs_and_derivs)
def pytest_sessionfinish(session, exitstatus):
if not hasattr(session.config, 'plots'): return
for method,(fig,axes) in session.config.plots.items():
axes[-1,-1].legend()
fig.suptitle(method.__name__)
fig.tight_layout()
pyplot.show()