Skip to content

Pretty-print expected and actual paths on assertion failures

Erwan Rouchet requested to merge elementpath-tests-print-paths into master

Added while working on !1951 (merged).

When some tests in arkindex.documents.tests.test_edit_elementpath fail, all we see is a whole bunch of UUIDs with very little meaning. This adds a custom failure message that prints the expected and the actual paths using element names instead of element IDs to make debugging quicker.

AssertionError: Element counts were not equal:
First has 1, Second has 0:  [UUID('cda5202f-b4d9-44ac-b715-2210f2be4403'), UUID('5c72a853-2ad8-4c60-b334-bf2ba7bd7c6d'), UUID('5c72a853-2ad8-4c60-b334-bf2ba7bd7c6d'), UUID('b11bb5d8-fe21-4c85-b446-1da4bf51d80e')]
First has 0, Second has 1:  [UUID('cda5202f-b4d9-44ac-b715-2210f2be4403'), UUID('5c72a853-2ad8-4c60-b334-bf2ba7bd7c6d'), UUID('b11bb5d8-fe21-4c85-b446-1da4bf51d80e')] : Expected paths (['X', 'A', 'B'], ['Y', 'A', 'B']) in element D, got [['Y', 'A', 'A', 'B'], ['X', 'A', 'B']]

Merge request reports

Loading