diff --git a/Tests/Functional/Python/PyExamples/CMakeLists.txt b/Tests/Functional/Python/PyExamples/CMakeLists.txt
index 8d3d23ce1c7c33f3a85699de35ece4a174c717b7..e00f1a45fb03a3ffa5e60525ce650772673fc2d2 100644
--- a/Tests/Functional/Python/PyExamples/CMakeLists.txt
+++ b/Tests/Functional/Python/PyExamples/CMakeLists.txt
@@ -12,13 +12,12 @@ file(GLOB sim_examples ${PY_EXAMPLES_DIR}/sim*/*.py)
 file(GLOB fit_examples ${PY_EXAMPLES_DIR}/fit55_Specular/FitSpecularBasics.py)
 set(examples ${sim_examples} ${fit_examples})
 
-set(test_script ${output_dir}/check_functionality.py)
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/check_functionality.in.py ${test_script} @ONLY)
+set(test_script ${CMAKE_CURRENT_SOURCE_DIR}/check_functionality.py)
 
 foreach(example_path ${examples})
     get_filename_component(example_name ${example_path} NAME_WE)
     set(test_name PyExamples.${example_name})
     add_test(${test_name}
         env PYTHONPATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
-        ${Python3_EXECUTABLE} ${test_script} ${example_path})
+        ${Python3_EXECUTABLE} ${test_script} ${example_path} ${output_dir})
 endforeach()
diff --git a/Tests/Functional/Python/PyExamples/check_functionality.in.py b/Tests/Functional/Python/PyExamples/check_functionality.py
similarity index 91%
rename from Tests/Functional/Python/PyExamples/check_functionality.in.py
rename to Tests/Functional/Python/PyExamples/check_functionality.py
index 51f6055be495637c3dc95875ff93ed5b09d81716..bd4e620d6fb27cf947a8681c46f5a74ebee6df2d 100644
--- a/Tests/Functional/Python/PyExamples/check_functionality.in.py
+++ b/Tests/Functional/Python/PyExamples/check_functionality.py
@@ -13,8 +13,6 @@ import matplotlib
 matplotlib.use('Agg')
 from matplotlib import pyplot as plt
 
-output_dir = "@output_dir@"
-
 
 def get_figure(filename):
     """
@@ -45,7 +43,7 @@ def exec_full(filepath):
         exec(compile(file.read(), filepath, 'exec'), global_namespace)
 
 
-def run_example(filename):
+def run_example(filename, output_dir):
     """
     Tries to run python example and produce a *.png image
     """
@@ -75,7 +73,7 @@ def run_example(filename):
 
 if __name__ == '__main__':
 
-    if len(sys.argv) != 2:
-        exit("check_functionality called with wrong number of arguments")
+    if len(sys.argv) != 3:
+        exit("Usage: check_functionality <script_to_test> <output_dir>")
 
-    run_example(sys.argv[1])
+    run_example(sys.argv[1], sys.argv[2])