alexander | f42f568 | 2021-07-16 11:30:56 +0100 | [diff] [blame^] | 1 | # Copyright © 2021 Arm Ltd and Contributors. All rights reserved. |
Éanna Ó Catháin | 145c88f | 2020-11-16 14:12:11 +0000 | [diff] [blame] | 2 | # SPDX-License-Identifier: MIT |
| 3 | |
| 4 | import os |
| 5 | import ntpath |
| 6 | |
| 7 | import urllib.request |
| 8 | import zipfile |
Éanna Ó Catháin | 145c88f | 2020-11-16 14:12:11 +0000 | [diff] [blame] | 9 | import pytest |
| 10 | |
| 11 | script_dir = os.path.dirname(__file__) |
alexander | f42f568 | 2021-07-16 11:30:56 +0100 | [diff] [blame^] | 12 | |
| 13 | |
Éanna Ó Catháin | 145c88f | 2020-11-16 14:12:11 +0000 | [diff] [blame] | 14 | @pytest.fixture(scope="session") |
alexander | f42f568 | 2021-07-16 11:30:56 +0100 | [diff] [blame^] | 15 | def test_data_folder(): |
Éanna Ó Catháin | 145c88f | 2020-11-16 14:12:11 +0000 | [diff] [blame] | 16 | """ |
| 17 | This fixture returns path to folder with shared test resources among all tests |
| 18 | """ |
| 19 | |
| 20 | data_dir = os.path.join(script_dir, "testdata") |
| 21 | if not os.path.exists(data_dir): |
| 22 | os.mkdir(data_dir) |
Éanna Ó Catháin | 145c88f | 2020-11-16 14:12:11 +0000 | [diff] [blame] | 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", |
alexander | f42f568 | 2021-07-16 11:30:56 +0100 | [diff] [blame^] | 26 | "https://github.com/ARM-software/ML-zoo/raw/master/models/object_detection/ssd_mobilenet_v1/tflite_uint8/ssd_mobilenet_v1.tflite", |
| 27 | "https://git.mlplatform.org/ml/ethos-u/ml-embedded-evaluation-kit.git/plain/resources/kws/samples/yes.wav", |
| 28 | "https://raw.githubusercontent.com/Azure-Samples/cognitive-services-speech-sdk/master/sampledata/audiofiles/myVoiceIsMyPassportVerifyMe04.wav" |
Éanna Ó Catháin | 145c88f | 2020-11-16 14:12:11 +0000 | [diff] [blame] | 29 | ] |
| 30 | |
| 31 | for file in files_to_download: |
| 32 | path, filename = ntpath.split(file) |
| 33 | file_path = os.path.join(data_dir, filename) |
| 34 | if not os.path.exists(file_path): |
| 35 | print("\nDownloading test file: " + file_path + "\n") |
| 36 | urllib.request.urlretrieve(file, file_path) |
| 37 | |
Éanna Ó Catháin | 145c88f | 2020-11-16 14:12:11 +0000 | [diff] [blame] | 38 | |
| 39 | return data_dir |