From dc60a0beb924b2879a75976e8fcab5de3de5355e Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Thu, 10 Oct 2024 14:33:24 +0200 Subject: Clean res dir before running pytest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pytest fails when rerun Change-Id: I957955300b2ef65bd1c5fdb28869921bca34ac57 Signed-off-by: Cédric Ollivier (cherry picked from commit ed61c53f85c9dcb5a5a3029c84d50100028d5e63) --- xtesting/core/pytest.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xtesting/core/pytest.py b/xtesting/core/pytest.py index 93e58211..c1e2c4ca 100644 --- a/xtesting/core/pytest.py +++ b/xtesting/core/pytest.py @@ -12,6 +12,8 @@ import contextlib import io import logging +import os +import shutil import time import pytest @@ -69,6 +71,8 @@ class Pytest(testcase.TestCase): status = self.EX_RUN_ERROR self.start_time = time.time() try: + if os.path.exists(os.path.join(self.dir_results, self.case_name)): + shutil.rmtree(os.path.join(self.dir_results, self.case_name)) pydir = kwargs.pop('dir') options = kwargs.pop('options', {}) options['html'] = f'{self.res_dir}/results.html' -- cgit 1.2.3-korg