11

実行中に大量の大きなファイルを作成するテストを実行しています。この目的のために、テストに合格した場合は tmpdir ディレクトリを削除したいと思います。ただし、テストが失敗した場合、tmpdir の内容は変更されないままにしておく必要があります。

テストの結果を判断する方法を知っています:

from _pytest.runner import runtestprotocol

def pytest_runtest_protocol(item, nextitem):
    reports = runtestprotocol(item, nextitem=nextitem)
    for report in reports:
        if report.when == 'call':
            # value will be set to passed or filed
            test_outcome = report.outcome
            # But what next?

return True

しかし、作成された tmpdir ディレクトリのパスを見つける方法がわかりません。

4

2 に答える 2