From 74e14a5dedeeba00fba0315329df0109977cab63 Mon Sep 17 00:00:00 2001
From: Stephan Seitz <stephan.seitz@fau.de>
Date: Thu, 23 Apr 2020 14:34:51 +0200
Subject: [PATCH] Skip llvm tests if llvmlite is not installed

---
 conftest.py                                        |  1 +
 pystencils_tests/test_jacobi_llvm.py               | 14 +++++++++-----
 .../test_size_and_layout_checks_llvm.py            |  6 +++++-
 pystencils_tests/test_sliced_iteration.py          |  2 ++
 4 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/conftest.py b/conftest.py
index 272f42303..d6b74818a 100644
--- a/conftest.py
+++ b/conftest.py
@@ -51,6 +51,7 @@ try:
     import llvmlite
 except ImportError:
     collect_ignore += [os.path.join(SCRIPT_FOLDER, 'pystencils_tests/backends/llvm.py')]
+    collect_ignore += [os.path.join(SCRIPT_FOLDER, 'pystencils_tests/test_basic_usage_llvm.ipynb')]
     add_path_to_ignore('pystencils/llvm')
 
 try:
diff --git a/pystencils_tests/test_jacobi_llvm.py b/pystencils_tests/test_jacobi_llvm.py
index 95bd52d2e..953432c11 100644
--- a/pystencils_tests/test_jacobi_llvm.py
+++ b/pystencils_tests/test_jacobi_llvm.py
@@ -1,10 +1,14 @@
-import numpy as np
+
 import pytest
+try:
+    from pystencils.llvm.llvmjit import generate_and_jit
+    from pystencils.llvm import create_kernel, make_python_function
+    from pystencils.cpu.cpujit import get_llc_command
+    from pystencils import Assignment, Field, show_code
+    import numpy as np
+except ModuleNotFoundError:
+    pytest.importorskip("llvmlite")
 
-from pystencils import Assignment, Field, show_code
-from pystencils.cpu.cpujit import get_llc_command
-from pystencils.llvm import create_kernel, make_python_function
-from pystencils.llvm.llvmjit import generate_and_jit
 
 
 def test_jacobi_fixed_field_size():
diff --git a/pystencils_tests/test_size_and_layout_checks_llvm.py b/pystencils_tests/test_size_and_layout_checks_llvm.py
index 8de8018f9..278ad1f20 100644
--- a/pystencils_tests/test_size_and_layout_checks_llvm.py
+++ b/pystencils_tests/test_size_and_layout_checks_llvm.py
@@ -1,7 +1,11 @@
 import numpy as np
+import pytest
 
 from pystencils import Assignment, Field
-from pystencils.llvm import create_kernel, make_python_function
+try:
+    from pystencils.llvm import create_kernel, make_python_function
+except ModuleNotFoundError:
+    pytest.importorskip("llvmlite")
 
 
 def test_size_check():
diff --git a/pystencils_tests/test_sliced_iteration.py b/pystencils_tests/test_sliced_iteration.py
index 174974568..761cae3f2 100644
--- a/pystencils_tests/test_sliced_iteration.py
+++ b/pystencils_tests/test_sliced_iteration.py
@@ -30,6 +30,8 @@ def test_sliced_iteration():
 
 
 def test_sliced_iteration_llvm():
+    import pytest
+    pytest.importorskip("llvmlite")
     size = (4, 4)
     src_arr = np.ones(size)
     dst_arr = np.zeros_like(src_arr)
-- 
GitLab