py.test:在测试后执行某些操作
答
这是在官方文档中找到的画布。
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.
...
http://pytest.org/latest/xunit_setup.html –
感谢您指点我。看起来[这个链接](http://pytest.org/latest/fixture.html#fixture-finalization-executing-teardown-code)更具有说服力。如果管理员想要关闭我的问题,他会做。 – projetmbc