Éanna Ó Catháin | 145c88f | 2020-11-16 14:12:11 +0000 | [diff] [blame] | 1 | # Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
|
| 2 | # SPDX-License-Identifier: MIT
|
| 3 |
|
| 4 | import os
|
| 5 | import ntpath
|
| 6 |
|
| 7 | import urllib.request
|
| 8 |
|
| 9 | import pytest
|
| 10 |
|
| 11 | script_dir = os.path.dirname(__file__)
|
| 12 |
|
| 13 | @pytest.fixture(scope="session")
|
| 14 | def 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 |
|
| 21 | if not os.path.exists(data_dir):
|
| 22 | os.mkdir(data_dir)
|
| 23 |
|
| 24 | files_to_download = ["https://raw.githubusercontent.com/Azure-Samples/cognitive-services-speech-sdk/master"
|
| 25 | "/sampledata/audiofiles/myVoiceIsMyPassportVerifyMe04.wav"]
|
| 26 |
|
| 27 | for file in files_to_download:
|
| 28 | path, filename = ntpath.split(file)
|
| 29 | file_path = os.path.join(script_dir, "testdata", filename)
|
| 30 | if not os.path.exists(file_path):
|
| 31 | print("\nDownloading test file: " + file_path + "\n")
|
| 32 | urllib.request.urlretrieve(file, file_path)
|
| 33 |
|
| 34 | return data_dir
|