Skip to content

Commit

Permalink
Move skip marks to tests/_helper.py (#653)
Browse files Browse the repository at this point in the history
  • Loading branch information
Elena Totmenina committed Dec 2, 2021
1 parent 343901a commit f93ca24
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
21 changes: 21 additions & 0 deletions numba_dppy/tests/_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import contextlib

import dpctl
import pytest
from numba.tests.support import captured_stdout

from numba_dppy import config
Expand Down Expand Up @@ -91,6 +92,26 @@ def skip_test(device_type):
return skip


skip_no_opencl_gpu = pytest.mark.skipif(
not has_opencl_gpu(),
reason="No opencl GPU platforms available",
)
skip_no_opencl_cpu = pytest.mark.skipif(
not has_opencl_cpu(),
reason="No opencl CPU platforms available",
)
skip_no_level_zero_gpu = pytest.mark.skipif(
not has_level_zero(),
reason="No level-zero GPU platforms available",
)

filter_strings = [
pytest.param("level_zero:gpu:0", marks=skip_no_level_zero_gpu),
pytest.param("opencl:gpu:0", marks=skip_no_opencl_gpu),
pytest.param("opencl:cpu:0", marks=skip_no_opencl_cpu),
]


@contextlib.contextmanager
def override_config(name, value, config=config):
"""
Expand Down
21 changes: 1 addition & 20 deletions numba_dppy/tests/test_with_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,7 @@
from numba_dppy import config

from . import _helper
from ._helper import assert_auto_offloading

skip_no_gpu = pytest.mark.skipif(
not _helper.has_opencl_gpu(),
reason="No opencl GPU platforms available",
)
skip_no_cpu = pytest.mark.skipif(
not _helper.has_opencl_cpu(),
reason="No opencl CPU platforms available",
)
skip_no_level_zero = pytest.mark.skipif(
not _helper.has_level_zero(),
reason="No level-zero GPU platforms available",
)

filter_strings = [
pytest.param("level_zero:gpu:0", marks=skip_no_level_zero),
pytest.param("opencl:gpu:0", marks=skip_no_gpu),
pytest.param("opencl:cpu:0", marks=skip_no_cpu),
]
from ._helper import assert_auto_offloading, filter_strings


def scenario(filter_str, context):
Expand Down

0 comments on commit f93ca24

Please sign in to comment.