tests: Simplify origin comparison and improve pytest diff on failure

By using a single equality instead of checking len() then zip()
to check one by one, pytest can find the common/missing elements
and print them nicely when the two lists are unequal.
This commit is contained in:
Valentin Lorentz 2022-08-24 17:21:24 +02:00
parent 4b511b4181
commit b7ec6cb120
8 changed files with 53 additions and 94 deletions

View file

@ -29,15 +29,9 @@ def bb_api_repositories_page2(datadir):
def _check_listed_origins(lister_origins, scheduler_origins):
"""Asserts that the two collections have the same origins from the point of view of
the lister"""
sorted_lister_origins = list(sorted(lister_origins))
sorted_scheduler_origins = list(sorted(scheduler_origins))
assert len(sorted_lister_origins) == len(sorted_scheduler_origins)
for lo, so in zip(sorted_lister_origins, sorted_scheduler_origins):
assert lo.url == so.url
assert lo.last_update == so.last_update
assert {(lo.url, lo.last_update) for lo in lister_origins} == {
(so.url, so.last_update) for so in scheduler_origins
}
def test_bitbucket_incremental_lister(