您如何在Python中声明一个空列表?

问题描述 投票:0回答:1
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"

当我输入一个空列表时它不响应测试用例,有办法吗?

python-3.x assert
1个回答
0
投票

如何声明一个空列表?

assert get_maximum(a) == []

或者,如果它总是返回列表并且您已经对其进行了测试:

assert not get_maximum(a)

并且之后无需添加该"Test case failed"

© www.soinside.com 2019 - 2024. All rights reserved.