Skip to content

Commit

Permalink
enh: print report only if there is regression tests in the session
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsbck committed Nov 22, 2024
1 parent 16d31b0 commit 28a52ee
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,18 @@ def get_or_compute_swc2jaxley_params(


@pytest.fixture(scope="session", autouse=True)
def print_session_report(request):
def print_session_report(request, pytestconfig):
"""Cleanup a testing directory once we are finished."""
NEW_BASELINE = os.environ["NEW_BASELINE"] if "NEW_BASELINE" in os.environ else 0

dirname = os.path.dirname(__file__)
baseline_fname = os.path.join(dirname, "regression_test_baselines.json")
results_fname = os.path.join(dirname, "regression_test_results.json")

collected_regression_tests = [
item for item in request.session.items if item.get_closest_marker("regression")
]

def update_baseline():
if NEW_BASELINE:
results = load_json(results_fname)
Expand All @@ -235,9 +239,9 @@ def print_regression_report():
# capturing the output and without specifying the "-s" flag
capmanager = request.config.pluginmanager.getplugin("capturemanager")
with capmanager.global_and_fixture_disabled():

print("\n\n\nRegression Test Report\n----------------------\n")
print(report)

request.addfinalizer(update_baseline)
request.addfinalizer(print_regression_report)
if len(collected_regression_tests) > 0:
request.addfinalizer(update_baseline)
request.addfinalizer(print_regression_report)

0 comments on commit 28a52ee

Please sign in to comment.