Matthew Bentham | 245d64c | 2019-12-02 12:59:43 +0000 | [diff] [blame] | 1 | # Copyright © 2019 Arm Ltd. All rights reserved. |
| 2 | # SPDX-License-Identifier: MIT |
| 3 | import os |
| 4 | |
| 5 | import pytest |
| 6 | |
| 7 | |
| 8 | @pytest.fixture(scope="module") |
| 9 | def data_folder_per_test(request): |
| 10 | """ |
| 11 | This fixture returns path to folder with test resources (one per test module) |
| 12 | """ |
| 13 | |
| 14 | basedir, script = request.fspath.dirname, request.fspath.basename |
| 15 | return str(os.path.join(basedir, "testdata", os.path.splitext(script)[0])) |
| 16 | |
| 17 | |
| 18 | @pytest.fixture(scope="module") |
| 19 | def shared_data_folder(request): |
| 20 | """ |
| 21 | This fixture returns path to folder with shared test resources among all tests |
| 22 | """ |
| 23 | |
| 24 | return str(os.path.join(request.fspath.dirname, "testdata", "shared")) |
| 25 | |
| 26 | |
| 27 | @pytest.fixture(scope="function") |
| 28 | def tmpdir(tmpdir): |
| 29 | """ |
| 30 | This fixture returns path to temp folder. Fixture was added for py35 compatibility |
| 31 | """ |
| 32 | |
| 33 | return str(tmpdir) |
| 34 | |
| 35 | |
| 36 | def pytest_addoption(parser): |
| 37 | parser.addoption('--juno', action='store_true', dest="juno", |
| 38 | default=False, help="enable juno fpga related tests") |
| 39 | |
| 40 | |
| 41 | def pytest_configure(config): |
| 42 | config.addinivalue_line( |
| 43 | "markers", "juno: mark test to run only on juno" |
| 44 | ) |
| 45 | |
| 46 | if not config.option.juno: |
| 47 | setattr(config.option, 'markexpr', 'not juno') |