Elle
Elle

Reputation: 75

How do you assert an empty list in Python?

def test_negative_case(get_maximum):
    a=[]
    assert get_maximum (1,3,k,)== None, "Test case failed"
    assert get_maximum(a)== None, "Test case failed"

It doesn't respond to the test case when I input an empty list, is there a way to do so?

Upvotes: 0

Views: 2088

Answers (1)

eumiro
eumiro

Reputation: 213025

How to assert an empty list?

assert get_maximum(a) == []

or, if it always returns a list and you already tested it:

assert not get_maximum(a)

And there's no need to add that "Test case failed" afterwards.

Upvotes: 5

Related Questions