diff options
author | jaseg <git@jaseg.de> | 2022-01-30 20:11:38 +0100 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2022-01-30 20:11:38 +0100 |
commit | c3ca4f95bd59f69d45e582a4149327f57a360760 (patch) | |
tree | 5f43c61a261698e2f671b5238a7aa9a71a0f6d23 /gerbonara/tests/conftest.py | |
parent | 259a56186820923c78a5688f59bd8249cf958b5f (diff) | |
download | gerbonara-c3ca4f95bd59f69d45e582a4149327f57a360760.tar.gz gerbonara-c3ca4f95bd59f69d45e582a4149327f57a360760.tar.bz2 gerbonara-c3ca4f95bd59f69d45e582a4149327f57a360760.zip |
Rename gerbonara/gerber package to just gerbonara
Diffstat (limited to 'gerbonara/tests/conftest.py')
-rw-r--r-- | gerbonara/tests/conftest.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/gerbonara/tests/conftest.py b/gerbonara/tests/conftest.py new file mode 100644 index 0000000..131ca28 --- /dev/null +++ b/gerbonara/tests/conftest.py @@ -0,0 +1,30 @@ + +from pathlib import Path + +import pytest + +from .image_support import ImageDifference + +def pytest_assertrepr_compare(op, left, right): + if isinstance(left, ImageDifference) or isinstance(right, ImageDifference): + diff = left if isinstance(left, ImageDifference) else right + return [ + f'Image difference assertion failed.', + f' Calculated difference: {diff}', + f' Histogram: {diff.histogram}', ] + +# store report in node object so tmp_gbr can determine if the test failed. +@pytest.hookimpl(tryfirst=True, hookwrapper=True) +def pytest_runtest_makereport(item, call): + outcome = yield + rep = outcome.get_result() + setattr(item, f'rep_{rep.when}', rep) + +fail_dir = Path('gerbonara_test_failures') +def pytest_sessionstart(session): + if not hasattr(session.config, 'workerinput'): # on worker + return + + # on coordinator + for f in chain(fail_dir.glob('*.gbr'), fail_dir.glob('*.png')): + f.unlink() |