From 4934a2c22560e48ca3e5e810429ff47ee8565515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20KUBLER?= <gregoire.kubler@proton.me> Date: Mon, 15 Jul 2024 09:56:00 +0200 Subject: [PATCH] fix : build dir rm before test --- aidge_core/unit_tests/test_export.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/aidge_core/unit_tests/test_export.py b/aidge_core/unit_tests/test_export.py index febeef96c..a0929eb96 100644 --- a/aidge_core/unit_tests/test_export.py +++ b/aidge_core/unit_tests/test_export.py @@ -10,14 +10,11 @@ SPDX-License-Identifier: EPL-2.0 import unittest import aidge_core -from functools import reduce import pathlib import os import sys import subprocess import shutil -import numpy as np - def initFiller(model): # Initialize parameters (weights and biases) @@ -43,6 +40,17 @@ def initFiller(model): else: pass +def clean_dir(dir : pathlib.Path) -> None: + for filename in os.listdir(dir): + file_path = os.path.join(dir, filename) + try: + if os.path.isfile(file_path) or os.path.islink(file_path): + os.unlink(file_path) + elif os.path.isdir(file_path): + shutil.rmtree(file_path) + except Exception as e: + print('Failed to delete %s. Reason: %s' % (file_path, e)) + return class test_export(unittest.TestCase): """Test aidge export""" @@ -74,6 +82,9 @@ class test_export(unittest.TestCase): # Export model aidge_core.export(self.EXPORT_PATH, model) + + + clean_dir(self.EXPORT_PATH / "build") self.assertTrue( self.EXPORT_PATH.is_dir(), "Export folder has not been generated" ) -- GitLab