How to use test_tar_dir method in avocado

Best Python code snippet using avocado_python

test.py

Source:test.py Github

copy

Full Screen

1from pathlib import Path2import subprocess3import tarfile4import os5from shutil import rmtree6TEST_ORT_DIR = 'ci_test_dir'7TEST_TAR_DIR = 'ci_test_tar_dir'8cwd_path = Path.cwd()9def get_model_directory(model_path):10 return os.path.dirname(model_path)11def install_lfs():12 result = subprocess.run(['git', 'lfs', 'install'], cwd=cwd_path, stdout=subprocess.PIPE, stderr=subprocess.PIPE)13 print(f'Git LFS install completed with return code= {result.returncode}')14def lfs_pull(file_name):15 result = subprocess.run(['git', 'lfs', 'pull', '--include', file_name, '--exclude', '\'\''], cwd='/root/workspace/models', stdout=subprocess.PIPE, stderr=subprocess.PIPE)16 print(f'LFS pull completed for {file_name} with return code= {result.returncode}')17def lfs_prune():18 result = subprocess.run(['git', 'lfs', 'prune'], cwd='/root/workspace/models', stdout=subprocess.PIPE, stderr=subprocess.PIPE)19 print(f'LFS prune completed with return code= {result.returncode}')20def extract_test_data(file_path):21 print(file_path)22 tar = tarfile.open(file_path, "r:gz")23 tar.extractall(TEST_TAR_DIR)24 tar.close()25 return get_model_and_test_data(TEST_TAR_DIR)26def get_model_and_test_data(directory_path):27 onnx_model = None28 test_data_set = []29 for root, dirs, files in os.walk(directory_path):30 for file in files:31 if file.endswith('.onnx'):32 file_path = os.path.join(root, file)33 assert onnx_model is None, "More than one ONNX model detected"34 onnx_model = file_path35 for subdir in dirs:36 # detect any test_data_set37 if subdir.startswith('test_data_set_'):38 subdir_path = os.path.join(root, subdir)39 test_data_set.append(subdir_path)40 return onnx_model, test_data_set41def remove_tar_dir():42 if os.path.exists(TEST_TAR_DIR) and os.path.isdir(TEST_TAR_DIR):43 rmtree(TEST_TAR_DIR)44def remove_onnxruntime_test_dir():45 if os.path.exists(TEST_ORT_DIR) and os.path.isdir(TEST_ORT_DIR):...

Full Screen

Full Screen

test_utils.py

Source:test_utils.py Github

copy

Full Screen

1# SPDX-License-Identifier: Apache-2.02from pathlib import Path3import subprocess4import tarfile5import os6import shutil7TEST_ORT_DIR = 'ci_test_dir'8TEST_TAR_DIR = 'ci_test_tar_dir'9cwd_path = Path.cwd()10def get_model_directory(model_path):11 return os.path.dirname(model_path)12def run_lfs_install():13 result = subprocess.run(['git', 'lfs', 'install'], cwd=cwd_path, stdout=subprocess.PIPE, stderr=subprocess.PIPE)14 print('Git LFS install completed with return code= {}'.format(result.returncode))15def pull_lfs_file(file_name):16 result = subprocess.run(['git', 'lfs', 'pull', '--include', file_name, '--exclude', '\'\''], cwd=cwd_path, stdout=subprocess.PIPE, stderr=subprocess.PIPE)17 print('LFS pull completed with return code= {}'.format(result.returncode))18def extract_test_data(file_path):19 tar = tarfile.open(file_path, "r:gz")20 tar.extractall(TEST_TAR_DIR)21 tar.close()22 return get_model_and_test_data(TEST_TAR_DIR)23def get_model_and_test_data(directory_path):24 onnx_model = None25 test_data_set = []26 for root, dirs, files in os.walk(directory_path):27 for file in files:28 if file.endswith('.onnx'):29 file_path = os.path.join(root, file)30 assert onnx_model is None, "More than one ONNX model detected"31 onnx_model = file_path32 for subdir in dirs:33 # detect any test_data_set34 if subdir.startswith('test_data_set_'):35 subdir_path = os.path.join(root, subdir)36 test_data_set.append(subdir_path)37 return onnx_model, test_data_set38def remove_tar_dir():39 if os.path.exists(TEST_TAR_DIR) and os.path.isdir(TEST_TAR_DIR):40 shutil.rmtree(TEST_TAR_DIR)41def remove_onnxruntime_test_dir():42 if os.path.exists(TEST_ORT_DIR) and os.path.isdir(TEST_ORT_DIR):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful