Clean res dir before running pytest 28/74628/1 master
authorCédric Ollivier <cedric.ollivier@orange.com>
Thu, 10 Oct 2024 12:33:24 +0000 (14:33 +0200)
committerCédric Ollivier <cedric.ollivier@orange.com>
Thu, 10 Oct 2024 12:33:24 +0000 (14:33 +0200)
Pytest fails when rerun

Change-Id: I957955300b2ef65bd1c5fdb28869921bca34ac57
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
xtesting/core/pytest.py

index 84d8ac5..a6735f1 100644 (file)
@@ -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'