Why not just compare the list directly?

assert list1() == list2()

But if you insist on testing element-wise:

@pytest.mark.parametrize(
    "one, two",             # these are the args of the test case
    zip(list1(), list2()),  # generate tuples to unpack into the args
)
def test_element(one, two):
    assert one == two

The test names will be messy, though. You may want to provide a list / iterator to ids to make the names look nicer.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top