Python-Hamcrest-测试列表是否不为空
在Hamcrest(python)中是否有一种干净的方法来测试列表是否为空。有几种方法可以通过检查列表长度等来实现,但我希望有一些内容能够很好地用于测试。使用Python-Hamcrest-测试列表是否不为空,python,hamcrest,Python,Hamcrest,在Hamcrest(python)中是否有一种干净的方法来测试列表是否为空。有几种方法可以通过检查列表长度等来实现,但我希望有一些内容能够很好地用于测试。使用空匹配器: assert_that(mylist, is_not(empty())) 我正在使用assertNotEqual([],list)检查列表是否为空最干净、可读性最好的方法可能是: from hamcrest import assert_that, is_, empty, not_ assert_that([], is_(no
空匹配器:
assert_that(mylist, is_not(empty()))
我正在使用assertNotEqual([],list)
检查列表是否为空最干净、可读性最好的方法可能是:
from hamcrest import assert_that, is_, empty, not_
assert_that([], is_(not_(empty())))
谢谢,但是我不能导入空的,它在pyhamcrest中似乎不存在。看起来hamcrest/library/collection/\u u init\uuuuuuuuuuy.py在is\u empty import empty中缺少。进行修复,然后提交拉取请求。