summaryrefslogtreecommitdiff
path: root/gerbonara/gerber/tests/conftest.py
blob: 0ad25557ec2fbe8bd1bebbdf1afd91379fb7cc9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import pytest

from .image_support import ImageDifference

@pytest.hookimpl(tryfirst=True, hookwrapper=True)
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'    Reference: {diff.ref_path}',
            f'    Actual: {diff.out_path}',
            f'    Calculated difference: {diff}', ]

# 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)