【发布时间】:2022-01-27 23:22:47
【问题描述】:
我遇到了一个基本否定单元测试的问题。尝试在最后一个函数中成功预期 NotFoundException 错误。 我遇到的问题是堆栈首先捕获错误并完全取消该 expect() 函数。请帮忙,TIA。
‘’’
def test_should_return_coffee_not_found(
coffee_information_repository_mock, coffee_information, coffee_drink
):
coffee_information_repository_mock.get_coffee_information.return_value = (
coffee_information
)
coffee_information_service = CoffeeInformationService(
coffee_information_repository_mock
)
result = coffee_information_service.get_drink_by_title("Gatorade")
expect(result).to(raise_error(NotFoundException))
‘’’
【问题讨论】:
标签: python unit-testing assertion