blob: b7fa73b85234c6032144397b88746c68a5e315a7 [file] [log] [blame]
alexanderf42f5682021-07-16 11:30:56 +01001# Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
Éanna Ó Catháin145c88f2020-11-16 14:12:11 +00002# SPDX-License-Identifier: MIT
3
4import os
5import ntpath
6
7import urllib.request
8import zipfile
Éanna Ó Catháin145c88f2020-11-16 14:12:11 +00009import pytest
10
11script_dir = os.path.dirname(__file__)
alexanderf42f5682021-07-16 11:30:56 +010012
13
Éanna Ó Catháin145c88f2020-11-16 14:12:11 +000014@pytest.fixture(scope="session")
alexanderf42f5682021-07-16 11:30:56 +010015def test_data_folder():
Éanna Ó Catháin145c88f2020-11-16 14:12:11 +000016 """
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áin145c88f2020-11-16 14:12:11 +000023 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",
alexanderf42f5682021-07-16 11:30:56 +010026 "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áin145c88f2020-11-16 14:12:11 +000029 ]
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áin145c88f2020-11-16 14:12:11 +000038
39 return data_dir