From 397cc790c211b121b6d6b6be260a553a21b07d67 Mon Sep 17 00:00:00 2001 From: Eden Date: Sun, 5 Apr 2026 20:17:09 +0800 Subject: [PATCH] fix: replace pytest.skip with requirement_not_met in conjugateGradientMultiBlockCG example The example imported pytest inside main() and used pytest.skip() for requirement checks, which is inappropriate for a standalone script. All other cuda.bindings examples use requirement_not_met() from _example_helpers for this purpose. Replace all pytest.skip() calls with requirement_not_met() and remove the local pytest import, aligning this example with the established pattern used across the rest of the examples directory. Fixes #1530 Relates to #1839 Signed-off-by: Eden --- .../conjugateGradientMultiBlockCG_test.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/cuda_bindings/examples/4_CUDA_Libraries/conjugateGradientMultiBlockCG_test.py b/cuda_bindings/examples/4_CUDA_Libraries/conjugateGradientMultiBlockCG_test.py index 44ff57c6d7..4f9aa4c182 100644 --- a/cuda_bindings/examples/4_CUDA_Libraries/conjugateGradientMultiBlockCG_test.py +++ b/cuda_bindings/examples/4_CUDA_Libraries/conjugateGradientMultiBlockCG_test.py @@ -26,6 +26,7 @@ KernelHelper, check_cuda_errors, find_cuda_device, + requirement_not_met, ) conjugate_gradient_multi_block_cg = """\ @@ -213,31 +214,29 @@ def gen_tridiag(i, j, val, n, nz): def main(): tol = 1e-5 - import pytest - # WAIVE: Due to bug in NVRTC - return + requirement_not_met("conjugateGradientMultiBlockCG is currently waived due to a known NVRTC issue") if platform.system() == "Darwin": - pytest.skip("conjugateGradientMultiBlockCG is not supported on Mac OSX") + requirement_not_met("conjugateGradientMultiBlockCG is not supported on Mac OSX") if platform.machine() == "armv7l": - pytest.skip("conjugateGradientMultiBlockCG is not supported on ARMv7") + requirement_not_met("conjugateGradientMultiBlockCG is not supported on ARMv7") if platform.machine() == "qnx": - pytest.skip("conjugateGradientMultiBlockCG is not supported on QNX") + requirement_not_met("conjugateGradientMultiBlockCG is not supported on QNX") # This will pick the best possible CUDA capable device dev_id = find_cuda_device() device_prop = check_cuda_errors(cudart.cudaGetDeviceProperties(dev_id)) if not device_prop.managedMemory: - pytest.skip("Unified Memory not supported on this device") + requirement_not_met("Unified Memory not supported on this device") # This sample requires being run on a device that supports Cooperative Kernel # Launch if not device_prop.cooperativeLaunch: - pytest.skip(f"Selected GPU {dev_id} does not support Cooperative Kernel Launch") + requirement_not_met(f"Selected GPU {dev_id} does not support Cooperative Kernel Launch") # Statistics about the GPU device print(