diff --git a/pystencils_tests/test_dtype_check.py b/pystencils_tests/test_dtype_check.py
index 842e89c247d16b0abea7be81ec1ae7dd8db7f6bd..194a6338fb32bb95b1cd6d5df3cd12640abdb7d8 100644
--- a/pystencils_tests/test_dtype_check.py
+++ b/pystencils_tests/test_dtype_check.py
@@ -16,7 +16,7 @@ def test_dtype_check_wrong_type():
 
     with pytest.raises(ValueError) as e:
         kernel(x=array, y=output)
-    assert 'Wrong data type' in str(e)
+    assert 'Wrong data type' in str(e.value)
 
 
 def test_dtype_check_correct_type():
diff --git a/pystencils_tests/test_fd_derivation.py b/pystencils_tests/test_fd_derivation.py
index 73d38dc10031ea3bb287d313c174bbbb96f8ff13..c2bb1aa08e7007e024aaf0867c15764c5e0880ce 100644
--- a/pystencils_tests/test_fd_derivation.py
+++ b/pystencils_tests/test_fd_derivation.py
@@ -31,4 +31,4 @@ def test_linear_equation_system():
 
     with pytest.raises(ValueError) as e:
         m.add_equation(x**2 - 1)
-    assert 'Not a linear equation' in str(e)
+    assert 'Not a linear equation' in str(e.value)
diff --git a/pystencils_tests/test_field.py b/pystencils_tests/test_field.py
index 4742282630dbf7046d73df791da8cbd02524e6b5..d4b9c6a38fba47648f1ae6cda1198ff45cfb3a83 100644
--- a/pystencils_tests/test_field.py
+++ b/pystencils_tests/test_field.py
@@ -40,56 +40,56 @@ def test_error_handling():
     Field.create_generic('f', spatial_dimensions=2, index_dimensions=0, dtype=struct_dtype)
     with pytest.raises(ValueError) as e:
         Field.create_generic('f', spatial_dimensions=2, index_dimensions=1, dtype=struct_dtype)
-    assert 'index dimension' in str(e)
+    assert 'index dimension' in str(e.value)
 
     arr = np.array([[1, 2.0, 3], [1, 2.0, 3]], dtype=struct_dtype)
     Field.create_from_numpy_array('f', arr, index_dimensions=0)
     with pytest.raises(ValueError) as e:
         Field.create_from_numpy_array('f', arr, index_dimensions=1)
-    assert 'Structured arrays' in str(e)
+    assert 'Structured arrays' in str(e.value)
 
     arr = np.zeros([3, 3, 3])
     Field.create_from_numpy_array('f', arr, index_dimensions=2)
     with pytest.raises(ValueError) as e:
         Field.create_from_numpy_array('f', arr, index_dimensions=3)
-    assert 'Too many' in str(e)
+    assert 'Too many' in str(e.value)
 
     Field.create_fixed_size('f', (3, 2, 4), index_dimensions=0, dtype=struct_dtype, layout='reverse_numpy')
     with pytest.raises(ValueError) as e:
         Field.create_fixed_size('f', (3, 2, 4), index_dimensions=1, dtype=struct_dtype, layout='reverse_numpy')
-    assert 'Structured arrays' in str(e)
+    assert 'Structured arrays' in str(e.value)
 
     f = Field.create_fixed_size('f', (10, 10))
     with pytest.raises(ValueError) as e:
         f[1]
-    assert 'Wrong number of spatial indices' in str(e)
+    assert 'Wrong number of spatial indices' in str(e.value)
 
     f = Field.create_generic('f', spatial_dimensions=2, index_shape=(3,))
     with pytest.raises(ValueError) as e:
         f(3)
-    assert 'out of bounds' in str(e)
+    assert 'out of bounds' in str(e.value)
 
     f = Field.create_fixed_size('f', (10, 10, 3, 4), index_dimensions=2)
     with pytest.raises(ValueError) as e:
         f(3, 0)
-    assert 'out of bounds' in str(e)
+    assert 'out of bounds' in str(e.value)
 
     with pytest.raises(ValueError) as e:
         f(1, 0)(1, 0)
-    assert 'Indexing an already indexed' in str(e)
+    assert 'Indexing an already indexed' in str(e.value)
 
     with pytest.raises(ValueError) as e:
         f(1)
-    assert 'Wrong number of indices' in str(e)
+    assert 'Wrong number of indices' in str(e.value)
 
     with pytest.raises(ValueError) as e:
         Field.create_generic('f', spatial_dimensions=2, layout='wrong')
-    assert 'Unknown layout descriptor' in str(e)
+    assert 'Unknown layout descriptor' in str(e.value)
 
     assert layout_string_to_tuple('fzyx', dim=4) == (3, 2, 1, 0)
     with pytest.raises(ValueError) as e:
         layout_string_to_tuple('wrong', dim=4)
-    assert 'Unknown layout descriptor' in str(e)
+    assert 'Unknown layout descriptor' in str(e.value)
 
 
 def test_decorator_scoping():
diff --git a/pystencils_tests/test_size_and_layout_checks.py b/pystencils_tests/test_size_and_layout_checks.py
index 597bf2c4d1ca32074e964141054e14313a288bea..27696e19fca91061b804a516a991d5c402e6cc05 100644
--- a/pystencils_tests/test_size_and_layout_checks.py
+++ b/pystencils_tests/test_size_and_layout_checks.py
@@ -23,7 +23,7 @@ def test_size_check():
 
     with pytest.raises(ValueError) as e:
         func(src=src, dst=dst)
-    assert 'Wrong shape' in str(e)
+    assert 'Wrong shape' in str(e.value)
 
 
 def test_fixed_size_mismatch_check():
@@ -38,7 +38,7 @@ def test_fixed_size_mismatch_check():
 
     with pytest.raises(ValueError) as e:
         create_kernel([update_rule])
-    assert 'Differently sized field accesses' in str(e)
+    assert 'Differently sized field accesses' in str(e.value)
 
 
 def test_fixed_and_variable_field_check():
@@ -53,7 +53,7 @@ def test_fixed_and_variable_field_check():
 
     with pytest.raises(ValueError) as e:
         create_kernel(update_rule)
-    assert 'Mixing fixed-shaped and variable-shape fields' in str(e)
+    assert 'Mixing fixed-shaped and variable-shape fields' in str(e.value)
 
 
 def test_two_variable_shaped_fields():
@@ -70,7 +70,7 @@ def test_two_variable_shaped_fields():
 
     with pytest.raises(TypeError) as e:
         func(src=src, dst=dst)
-    assert 'must have same' in str(e)
+    assert 'must have same' in str(e.value)
 
 
 def test_ssa_checks():
@@ -81,18 +81,18 @@ def test_ssa_checks():
         create_kernel([Assignment(c, f[0, 1]),
                        Assignment(c, f[1, 0]),
                        Assignment(g[0, 0], c)])
-    assert 'Assignments not in SSA form' in str(e)
+    assert 'Assignments not in SSA form' in str(e.value)
 
     with pytest.raises(ValueError) as e:
         create_kernel([Assignment(c, a + 3),
                        Assignment(a, 42),
                        Assignment(g[0, 0], c)])
-    assert 'Symbol a is written, after it has been read' in str(e)
+    assert 'Symbol a is written, after it has been read' in str(e.value)
 
     with pytest.raises(ValueError) as e:
         create_kernel([Assignment(c, c + 1),
                        Assignment(g[0, 0], c)])
-    assert 'Symbol c is written, after it has been read' in str(e)
+    assert 'Symbol c is written, after it has been read' in str(e.value)
 
 
 def test_loop_independence_checks():
@@ -102,7 +102,7 @@ def test_loop_independence_checks():
     with pytest.raises(ValueError) as e:
         create_kernel([Assignment(g[0, 1], f[0, 1]),
                        Assignment(g[0, 0], f[1, 0])])
-    assert 'Field g is written at two different locations' in str(e)
+    assert 'Field g is written at two different locations' in str(e.value)
 
     # This is allowed - because only one element of g is accessed
     create_kernel([Assignment(g[0, 2], f[0, 1]),
@@ -115,4 +115,4 @@ def test_loop_independence_checks():
     with pytest.raises(ValueError) as e:
         create_kernel([Assignment(g[0, 1], 3),
                        Assignment(f[0, 1], 2 * g[0, 2])])
-    assert 'Field g is read at (0, 2) and written at (0, 1)' in str(e)
+    assert 'Field g is read at (0, 2) and written at (0, 1)' in str(e.value)