blob: 40576c3aac7f5b15c926b3d06bccdc47a5434daa (
plain) (
blame)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 | import difflib
def iter_diff(fr, to):
    for l in difflib.unified_diff(fr.splitlines(), to.splitlines(), fromfile='L', tofile='R'):
        l = l.rstrip('\n')
        if l:
            if l[0] == '-':
                l = '[[bad]]' + l + '[[rst]]'
            elif l[0] == '+':
                l = '[[good]]' + l + '[[rst]]'
        yield l
def pytest_assertrepr_compare(op, left, right):
    return ['failed, show diff'] + list(iter_diff(left, right))
 |