| 1 | import pytest |
| 2 | import tempfile |
| 3 | from nixio.test.xcompat.compile import maketests |
| 4 | |
| 5 | |
| 6 | BINDIR = tempfile.mkdtemp(prefix="nixpy-tests-") |
| 7 | |
| 8 | |
| 9 | def pytest_addoption(parser): |
| 10 | parser.addoption("--nix-compat", action="store_true", default=False, |
| 11 | help=("Run nix compatibility tests " |
| 12 | "(requires NIX library)")) |
| 13 | |
| 14 | |
| 15 | @pytest.fixture |
| 16 | def bindir(request): |
| 17 | return BINDIR |
| 18 | |
| 19 | |
| 20 | def pytest_collection_modifyitems(config, items): |
| 21 | if config.getoption("--nix-compat"): |
| 22 | print("Compiling NIX compatibility tests") |
| 23 | maketests(BINDIR) |
| 24 | return |
| 25 | skip_compat = pytest.mark.skip( |
| 26 | reason="Use --nix-compat option to run compatibility tests" |
| 27 | ) |
| 28 | for item in items: |
| 29 | if "compatibility" in item.keywords: |
| 30 | item.add_marker(skip_compat) |