1# Copyright © 2020 Arm Ltd and Contributors. All rights reserved. 2# SPDX-License-Identifier: MIT 3 4import os 5import ntpath 6 7import urllib.request 8import zipfile 9 10import pytest 11 12script_dir = os.path.dirname(__file__) 13@pytest.fixture(scope="session") 14def test_data_folder(request): 15 """ 16 This fixture returns path to folder with shared test resources among all tests 17 """ 18 19 data_dir = os.path.join(script_dir, "testdata") 20 if not os.path.exists(data_dir): 21 os.mkdir(data_dir) 22 23 files_to_download = ["https://raw.githubusercontent.com/opencv/opencv/4.0.0/samples/data/messi5.jpg", 24 "https://raw.githubusercontent.com/opencv/opencv/4.0.0/samples/data/basketball1.png", 25 "https://raw.githubusercontent.com/opencv/opencv/4.0.0/samples/data/Megamind.avi", 26 "https://storage.googleapis.com/download.tensorflow.org/models/tflite/coco_ssd_mobilenet_v1_1.0_quant_2018_06_29.zip" 27 ] 28 29 for file in files_to_download: 30 path, filename = ntpath.split(file) 31 file_path = os.path.join(data_dir, filename) 32 if not os.path.exists(file_path): 33 print("\nDownloading test file: " + file_path + "\n") 34 urllib.request.urlretrieve(file, file_path) 35 36 # Any unzipping needed, and moving around of files 37 with zipfile.ZipFile(os.path.join(data_dir, "coco_ssd_mobilenet_v1_1.0_quant_2018_06_29.zip"), 'r') as zip_ref: 38 zip_ref.extractall(data_dir) 39 40 return data_dir 41