[pytest]如何测试正确的'错误'? 使用pytest进行异常测试

使用pytest.raises来进行对异常的测试

import pytest


def test_error():
    with pytest.raises(ZeroDivisionError):
        1 / 0

 

posted @ 2020-12-09 15:48  algxbi  阅读(301)  评论(0)    收藏  举报