对于我的测试,我构建临时文件,我想删除测试结果(失败或测试通过)。
有没有办法在完成测试我的Python文件之后“告诉”py.test
做某事?
答案 0 :(得分:0)
这是官方文档中的画布。
from pytest import fixture
@fixture(scope="module")
def or_datas(request):
# Something done before a test.
def fin():
# Here, just do something after the test.
...
request.addfinalizer(fin)
# How to use it ?
def test_something(or_datas):
# Note the argument corresponding the function decorated
# by fixture.
...