summaryrefslogtreecommitdiffstats
path: root/tests/plugin_tests/numpy3_test.py
blob: 9b252fb8da6044fdad38d5a694e2ea0b2eedccf4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os

import pytest

from debputy.plugin.api.test_api import (
    initialize_plugin_under_test,
    build_virtual_file_system,
    package_metadata_context,
)

DATA_FILE = os.path.join(os.path.dirname(__file__), "numpy3_test.data")


@pytest.fixture(scope="session")
def numpy3_stub_data_file() -> None:
    os.environ["_NUMPY_TEST_PATH"] = DATA_FILE
    yield
    try:
        del os.environ["_NUMPY_TEST_PATH"]
    except KeyError:
        pass


def test_numpy3_plugin_arch_all(numpy3_stub_data_file) -> None:
    plugin = initialize_plugin_under_test()
    fs = build_virtual_file_system([])
    context = package_metadata_context(package_fields={"Architecture": "all"})
    metadata = plugin.run_metadata_detector("numpy-depends", fs, context)
    assert metadata.substvars["python3:Depends"] == "python3-numpy"


def test_numpy3_plugin_arch_any(numpy3_stub_data_file) -> None:
    plugin = initialize_plugin_under_test()
    fs = build_virtual_file_system([])
    context = package_metadata_context(package_fields={"Architecture": "any"})
    metadata = plugin.run_metadata_detector("numpy-depends", fs, context)
    expected = "python3-numpy (>= 1:1.22.0), python3-numpy-abi9"
    assert metadata.substvars["python3:Depends"] == expected