diff --git a/conftest.py b/conftest.py new file mode 100644 index 0000000000000000000000000000000000000000..dc63579adb5103130130d719a9cba738936c11de --- /dev/null +++ b/conftest.py @@ -0,0 +1,17 @@ +import os +import shutil + +import pytest + + +@pytest.fixture(autouse=True, scope='class') +def teardown_module(pytestconfig): + yield + # dirname can be found at pytestconfig._assertstate.hook.session._initialparts[0][0].dirname but it is not clear for + # me, if there can be more than 1 entry in each of the lists. Therefore just loop over all elements will definitely + # catch all dirnames. + d = pytestconfig._assertstate.hook.session._initialparts + for di in d: + for dii in di: + if "data" in os.listdir(dii.dirname): + shutil.rmtree(os.path.join(dii.dirname, "data"), ignore_errors=True)