Best Python code snippet using avocado_python
test.py
Source: test.py
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):...
test_utils.py
Source: test_utils.py
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):...
Check out the latest blogs from LambdaTest on this topic:
Hola Testers! Hope you all had a great Thanksgiving weekend! To make this time more memorable, we at LambdaTest have something to offer you as a token of appreciation.
In addition to the four values, the Agile Manifesto contains twelve principles that are used as guides for all methodologies included under the Agile movement, such as XP, Scrum, and Kanban.
JavaScript is one of the most widely used programming languages. This popularity invites a lot of JavaScript development and testing frameworks to ease the process of working with it. As a result, numerous JavaScript testing frameworks can be used to perform unit testing.
When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.
The rapid shift in the use of technology has impacted testing and quality assurance significantly, especially around the cloud adoption of agile development methodologies. With this, the increasing importance of quality and automation testing has risen enough to deliver quality work.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!