diff --git a/tests/test_benchmark.py b/tests/test_benchmark.py
index 63be8ff1965aeab054bb996e0e08a1a1b2233be8..ea2b3bc656f7b298249966a6b040fe2fa140d0f6 100755
--- a/tests/test_benchmark.py
+++ b/tests/test_benchmark.py
@@ -1,14 +1,13 @@
 import subprocess
 import numpy as np
 import sympy as sp
+import tempfile
 import pystencils as ps
-from pystencils_benchmark import generate_benchmark, Compiler
 from pathlib import Path
+from pystencils_benchmark import generate_benchmark, Compiler
 
 
 def test_generate():
-    path = Path.cwd() / 'test'
-    path.mkdir(parents=True, exist_ok=True)
     a, b, c = ps.fields(a=np.ones(4000000), b=np.ones(4000000), c=np.ones(4000000))
     alpha = sp.symbols('alpha')
 
@@ -23,7 +22,10 @@ def test_generate():
     kernel_daxpy = ps.create_kernel(**daxpy)
 
     for compiler in [Compiler.GCC, Compiler.GCCdebug, Compiler.Clang]:
-        generate_benchmark([kernel_vadd, kernel_daxpy], path, compiler=compiler)
-        subprocess.run(['make', '-C', f'{path}'], check=True)
-        subprocess.run([f'{path}/benchmark-{compiler.name}', '10'], check=True)
+        with tempfile.TemporaryDirectory(dir=Path.cwd()) as temp_dir:
+            temp_dir = Path(temp_dir)
+            generate_benchmark([kernel_vadd, kernel_daxpy], temp_dir, compiler=compiler)
+            subprocess.run(['make', '-C', f'{temp_dir}'], check=True)
+            subprocess.run([f'{temp_dir}/benchmark-{compiler.name}', '10'], check=True)
+
 
diff --git a/tests/test_benchmark_vector.py b/tests/test_benchmark_vector.py
index 5f73e77244ffb1ad29b9fba424018ae90a3dd3ba..6fe2a6ebb1c7a4dc66912dda8a275689a0261f05 100644
--- a/tests/test_benchmark_vector.py
+++ b/tests/test_benchmark_vector.py
@@ -1,14 +1,13 @@
 import subprocess
 import numpy as np
 import sympy as sp
+import tempfile
 import pystencils as ps
-from pystencils_benchmark import generate_benchmark, Compiler
 from pathlib import Path
+from pystencils_benchmark import generate_benchmark, Compiler
 
 
 def test_generate():
-    path = Path.cwd() / 'test'
-    path.mkdir(parents=True, exist_ok=True)
     a, b, c = ps.fields(a=np.ones(4000000), b=np.ones(4000000), c=np.ones(4000000))
     alpha = sp.symbols('alpha')
 
@@ -23,7 +22,10 @@ def test_generate():
     kernel_daxpy = ps.create_kernel(**daxpy)
 
     for compiler in [Compiler.GCC, Compiler.GCCdebug, Compiler.Clang]:
-        generate_benchmark([kernel_vadd, kernel_daxpy], path, compiler=compiler)
-        subprocess.run(['make', '-C', f'{path}'], check=True)
-        subprocess.run([f'{path}/benchmark-{compiler.name}', '10'], check=True)
+        with tempfile.TemporaryDirectory(dir=Path.cwd()) as temp_dir:
+            temp_dir = Path(temp_dir)
+            generate_benchmark([kernel_vadd, kernel_daxpy], temp_dir, compiler=compiler)
+            subprocess.run(['make', '-C', f'{temp_dir}'], check=True)
+            subprocess.run([f'{temp_dir}/benchmark-{compiler.name}', '10'], check=True)
+