diff --git a/CHANGELOG.md b/CHANGELOG.md index cb8e794ba1..37109b303b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,7 @@ The full list of changes that went into this release are: * Avoid dead-locking by releasing GIL around blocking operations in libtensor [gh-1753](https://github.com/IntelPython/dpctl/pull/1753) * Element-wise `tensor.divide` and comparison operations allow greater range of Python integer and integer array combinations [gh-1771](https://github.com/IntelPython/dpctl/pull/1771) * Fix for unexpected behavior when using floating point types for array indexing [gh-1792](https://github.com/IntelPython/dpctl/pull/1792) +* Enable `pytest --pyargs dpctl.tests` [gh-1833](https://github.com/IntelPython/dpctl/pull/1833) ### Maintenance diff --git a/dpctl/tests/__init__.py b/dpctl/tests/__init__.py new file mode 100644 index 0000000000..db22daca21 --- /dev/null +++ b/dpctl/tests/__init__.py @@ -0,0 +1,19 @@ +# Data Parallel Control (dpctl) +# +# Copyright 2020-2024 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +__doc__ = r""" +Test suite of `dpctl`. Running test suite requires Cython, +and a working compiler.""" diff --git a/dpctl/tests/conftest.py b/dpctl/tests/conftest.py index b4d013a0dc..ebc54bca60 100644 --- a/dpctl/tests/conftest.py +++ b/dpctl/tests/conftest.py @@ -21,13 +21,14 @@ import sys import pytest -from _device_attributes_checks import ( + +from ._device_attributes_checks import ( check, device_selector, invalid_filter, valid_filter, ) -from _numpy_warnings import suppress_invalid_numpy_warnings +from ._numpy_warnings import suppress_invalid_numpy_warnings sys.path.append(os.path.join(os.path.dirname(__file__), "helper")) diff --git a/dpctl/tests/test_sycl_context.py b/dpctl/tests/test_sycl_context.py index e0c844e6ff..5217512f8b 100644 --- a/dpctl/tests/test_sycl_context.py +++ b/dpctl/tests/test_sycl_context.py @@ -18,10 +18,11 @@ """ import pytest -from helper import create_invalid_capsule import dpctl +from .helper import create_invalid_capsule + list_of_valid_filter_selectors = [ "opencl", "opencl:gpu", diff --git a/dpctl/tests/test_sycl_device.py b/dpctl/tests/test_sycl_device.py index e85259321b..e97c6d2f00 100644 --- a/dpctl/tests/test_sycl_device.py +++ b/dpctl/tests/test_sycl_device.py @@ -18,11 +18,12 @@ """ import pytest -from helper import get_queue_or_skip import dpctl from dpctl import SyclDeviceCreationError +from .helper import get_queue_or_skip + def test_standard_selectors(device_selector, check): """Tests if the standard SYCL device_selectors are able to select a diff --git a/dpctl/tests/test_sycl_event.py b/dpctl/tests/test_sycl_event.py index 6423665074..06409a342d 100644 --- a/dpctl/tests/test_sycl_event.py +++ b/dpctl/tests/test_sycl_event.py @@ -18,7 +18,6 @@ """ import pytest -from helper import create_invalid_capsule import dpctl import dpctl.memory as dpctl_mem @@ -26,6 +25,8 @@ import dpctl.tensor as dpt from dpctl import event_status_type as esty +from .helper import create_invalid_capsule + def produce_event(profiling=False): oclSrc = " \ diff --git a/dpctl/tests/test_sycl_platform.py b/dpctl/tests/test_sycl_platform.py index e795c2315c..c9d5cdf6ed 100644 --- a/dpctl/tests/test_sycl_platform.py +++ b/dpctl/tests/test_sycl_platform.py @@ -20,10 +20,11 @@ import sys import pytest -from helper import has_sycl_platforms import dpctl +from .helper import has_sycl_platforms + list_of_valid_filter_selectors = [ "opencl", "opencl:gpu", diff --git a/dpctl/tests/test_sycl_queue.py b/dpctl/tests/test_sycl_queue.py index b7f42ffb44..f9dcb8a924 100644 --- a/dpctl/tests/test_sycl_queue.py +++ b/dpctl/tests/test_sycl_queue.py @@ -21,10 +21,11 @@ import sys import pytest -from helper import create_invalid_capsule import dpctl +from .helper import create_invalid_capsule + def test_standard_selectors(device_selector, check): """ diff --git a/dpctl/tests/test_tensor_accumulation.py b/dpctl/tests/test_tensor_accumulation.py index 97194ed5eb..557cd3b3ff 100644 --- a/dpctl/tests/test_tensor_accumulation.py +++ b/dpctl/tests/test_tensor_accumulation.py @@ -17,11 +17,12 @@ from random import randrange import pytest -from helper import get_queue_or_skip, skip_if_dtype_not_supported import dpctl.tensor as dpt from dpctl.utils import ExecutionPlacementError +from .helper import get_queue_or_skip, skip_if_dtype_not_supported + sint_types = [ dpt.int8, dpt.int16, diff --git a/dpctl/tests/test_tensor_asarray.py b/dpctl/tests/test_tensor_asarray.py index dc0f81591a..939167126a 100644 --- a/dpctl/tests/test_tensor_asarray.py +++ b/dpctl/tests/test_tensor_asarray.py @@ -16,11 +16,12 @@ import numpy as np import pytest -from helper import get_queue_or_skip import dpctl import dpctl.tensor as dpt +from .helper import get_queue_or_skip + @pytest.mark.parametrize( "src_usm_type, dst_usm_type", diff --git a/dpctl/tests/test_tensor_clip.py b/dpctl/tests/test_tensor_clip.py index 433f22c58f..13b7b66087 100644 --- a/dpctl/tests/test_tensor_clip.py +++ b/dpctl/tests/test_tensor_clip.py @@ -16,7 +16,6 @@ import numpy as np import pytest -from helper import get_queue_or_skip, skip_if_dtype_not_supported from numpy.testing import assert_raises_regex import dpctl @@ -29,6 +28,8 @@ ) from dpctl.utils import ExecutionPlacementError +from .helper import get_queue_or_skip, skip_if_dtype_not_supported + _all_dtypes = [ "?", "u1", diff --git a/dpctl/tests/test_usm_ndarray_ctor.py b/dpctl/tests/test_usm_ndarray_ctor.py index 9f2a70b990..5b50d28d1b 100644 --- a/dpctl/tests/test_usm_ndarray_ctor.py +++ b/dpctl/tests/test_usm_ndarray_ctor.py @@ -20,13 +20,14 @@ import numpy as np import pytest -from helper import get_queue_or_skip, skip_if_dtype_not_supported import dpctl import dpctl.memory as dpm import dpctl.tensor as dpt from dpctl.tensor import Device +from .helper import get_queue_or_skip, skip_if_dtype_not_supported + @pytest.mark.parametrize( "shape", diff --git a/dpctl/tests/test_usm_ndarray_dlpack.py b/dpctl/tests/test_usm_ndarray_dlpack.py index 2f07abf12a..92531e21a1 100644 --- a/dpctl/tests/test_usm_ndarray_dlpack.py +++ b/dpctl/tests/test_usm_ndarray_dlpack.py @@ -19,13 +19,14 @@ import numpy as np import pytest -from helper import get_queue_or_skip, skip_if_dtype_not_supported import dpctl import dpctl.tensor as dpt import dpctl.tensor._dlpack as _dlp import dpctl.tensor._usmarray as dpt_arr +from .helper import get_queue_or_skip, skip_if_dtype_not_supported + device_CPU = dpt_arr.DLDeviceType.kDLCPU device_oneAPI = dpt_arr.DLDeviceType.kDLOneAPI diff --git a/dpctl/tests/test_usm_ndarray_indexing.py b/dpctl/tests/test_usm_ndarray_indexing.py index 71ba738f4a..1028c39e08 100644 --- a/dpctl/tests/test_usm_ndarray_indexing.py +++ b/dpctl/tests/test_usm_ndarray_indexing.py @@ -17,7 +17,6 @@ import numpy as np import pytest -from helper import get_queue_or_skip, skip_if_dtype_not_supported from numpy.testing import assert_array_equal import dpctl @@ -25,6 +24,8 @@ import dpctl.tensor._tensor_impl as ti from dpctl.utils import ExecutionPlacementError +from .helper import get_queue_or_skip, skip_if_dtype_not_supported + _all_dtypes = [ "u1", "i1", diff --git a/dpctl/tests/test_usm_ndarray_print.py b/dpctl/tests/test_usm_ndarray_print.py index 983cb75d98..19b3b83ba4 100644 --- a/dpctl/tests/test_usm_ndarray_print.py +++ b/dpctl/tests/test_usm_ndarray_print.py @@ -16,11 +16,12 @@ import numpy as np import pytest -from helper import get_queue_or_skip, skip_if_dtype_not_supported import dpctl import dpctl.tensor as dpt +from .helper import get_queue_or_skip, skip_if_dtype_not_supported + class TestPrint: def setup_method(self): diff --git a/dpctl/tests/test_usm_ndarray_search_functions.py b/dpctl/tests/test_usm_ndarray_search_functions.py index aba0142ee0..a646f4cde1 100644 --- a/dpctl/tests/test_usm_ndarray_search_functions.py +++ b/dpctl/tests/test_usm_ndarray_search_functions.py @@ -19,7 +19,6 @@ import numpy as np import pytest -from helper import get_queue_or_skip, skip_if_dtype_not_supported from numpy.testing import assert_array_equal import dpctl.tensor as dpt @@ -27,6 +26,8 @@ from dpctl.tensor._type_utils import _all_data_types from dpctl.utils import ExecutionPlacementError +from .helper import get_queue_or_skip, skip_if_dtype_not_supported + _all_dtypes = [ "?", "u1", diff --git a/dpctl/tests/test_usm_ndarray_searchsorted.py b/dpctl/tests/test_usm_ndarray_searchsorted.py index 47dd97bc87..dfec24de08 100644 --- a/dpctl/tests/test_usm_ndarray_searchsorted.py +++ b/dpctl/tests/test_usm_ndarray_searchsorted.py @@ -1,11 +1,12 @@ import numpy as np import pytest -from helper import get_queue_or_skip, skip_if_dtype_not_supported import dpctl import dpctl.tensor as dpt import dpctl.utils as dpu +from .helper import get_queue_or_skip, skip_if_dtype_not_supported + def _check(hay_stack, needles, needles_np): assert hay_stack.dtype == needles.dtype