1# Copyright © 2020 Arm Ltd. All rights reserved. 2# SPDX-License-Identifier: MIT 3import os 4import platform 5 6import pytest 7 8ARCHITECTURES = set("x86_64 aarch64".split()) 9 10 11@pytest.fixture(scope="module") 12def data_folder_per_test(request): 13 """ 14 This fixture returns path to folder with test resources (one per test module) 15 """ 16 17 basedir, script = request.fspath.dirname, request.fspath.basename 18 return str(os.path.join(basedir, "testdata", os.path.splitext(script)[0])) 19 20 21@pytest.fixture(scope="module") 22def shared_data_folder(request): 23 """ 24 This fixture returns path to folder with shared test resources among all tests 25 """ 26 27 return str(os.path.join(request.fspath.dirname, "testdata", "shared")) 28 29 30@pytest.fixture(scope="function") 31def tmpdir(tmpdir): 32 """ 33 This fixture returns path to temp folder. Fixture was added for py35 compatibility 34 """ 35 36 return str(tmpdir) 37 38 39def pytest_runtest_setup(item): 40 supported_architectures = ARCHITECTURES.intersection(mark.name for mark in item.iter_markers()) 41 arch = platform.machine() 42 if supported_architectures and arch not in supported_architectures: 43 pytest.skip("cannot run on platform {}".format(arch)) 44 45 46def pytest_configure(config): 47 config.addinivalue_line( 48 "markers", "aarch64: mark test to run only on aarch64" 49 ) 50 config.addinivalue_line( 51 "markers", "x86_64: mark test to run only on x86_64" 52 )