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

@ -51,14 +51,7 @@ def check_listed_origins(lister_urls: List[str], scheduler_origins: List[ListedO
"""Asserts that the two collections have the same origin URLs.
Does not test last_update."""
sorted_lister_urls = list(sorted(lister_urls))
sorted_scheduler_origins = list(sorted(scheduler_origins))
assert len(sorted_lister_urls) == len(sorted_scheduler_origins)
for l_url, s_origin in zip(sorted_lister_urls, sorted_scheduler_origins):
assert l_url == s_origin.url
assert set(lister_urls) == {origin.url for origin in scheduler_origins}
def test_gitea_full_listing(