May 12, 2022    Share on: Twitter | Facebook | HackerNews | Reddit

Pytest check if lists are equal

In the assertions this can be useful to check if two lists are equal:

def check_lists_equal(list_1: list, list_2: list) -> bool:
    """Check if two lists are equal."""
    return len(list_1) == len(list_2) and sorted(list_1) == sorted(list_2)



Tags:  pytest python assert