From 3814a508001564b8a84d546f61eec83173659639 Mon Sep 17 00:00:00 2001 From: Stephan Seitz <stephan.seitz@fau.de> Date: Tue, 13 Aug 2019 16:29:23 +0200 Subject: [PATCH] Skip opencljit test if pyopencl is not installed --- pystencils_tests/test_opencl.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pystencils_tests/test_opencl.py b/pystencils_tests/test_opencl.py index 5216d52..dfeab79 100644 --- a/pystencils_tests/test_opencl.py +++ b/pystencils_tests/test_opencl.py @@ -1,5 +1,5 @@ import numpy as np -import pyopencl as cl +import pytest import sympy as sp import pystencils @@ -7,6 +7,12 @@ from pystencils.backends.cuda_backend import CudaBackend from pystencils.backends.opencl_backend import OpenClBackend from pystencils.opencl.opencljit import make_python_function +try: + import pyopencl as cl + HAS_OPENCL = True +except Exception: + HAS_OPENCL = False + def test_print_opencl(): z, y, x = pystencils.fields("z, y, x: [2d]") @@ -32,6 +38,7 @@ def test_print_opencl(): assert "get_local_id(0)" in str(opencl_code) +@pytest.mark.skipif(not HAS_OPENCL, reason="Test requires pyopencl") def test_opencl_jit(): z, y, x = pystencils.fields("z, y, x: [20,30]") -- GitLab