From b693cf60386cd394c89a9b9f258d3af55dd59b0f Mon Sep 17 00:00:00 2001 From: madhanmellanox <62459540+madhanmellanox@users.noreply.github.com> Date: Mon, 9 Nov 2020 11:55:50 -0800 Subject: [PATCH] Remove SKU create pytest output directory before execution of the script (#1226) Remove SKU create pytest output directory before execution of the script Co-authored-by: Madhan Babu --- tests/sku_create_test.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/sku_create_test.py b/tests/sku_create_test.py index c9cb6c787029..562ff8cdb538 100644 --- a/tests/sku_create_test.py +++ b/tests/sku_create_test.py @@ -1,13 +1,16 @@ -import sys import os -import pytest -import subprocess import re +import shutil +import subprocess +import sys + +import pytest test_path = os.path.dirname(os.path.abspath(__file__)) modules_path = os.path.dirname(test_path) scripts_path = os.path.join(modules_path, "scripts") input_path = os.path.join(modules_path, "tests/sku_create_input") +output_dir_path = os.path.join(modules_path, "tests/sku_create_input/Mellanox-SN2700-D48C8_NEW") sku_def_file = os.path.join(input_path, "Mellanox-SN2700-D48C8.xml") sku_create_script = os.path.join(scripts_path, "sonic_sku_create.py") output_file_path = os.path.join(modules_path, "tests/sku_create_input/Mellanox-SN2700-D48C8_NEW/port_config.ini") @@ -49,6 +52,9 @@ def are_file_contents_same(self,fname1,fname2): return True def test_no_param(self): + if (os.path.exists(output_dir_path)): + shutil.rmtree(output_dir_path) + my_command = sku_create_script + " -f " + sku_def_file + " -d " + input_path #Test case execution without stdout