diff --git a/.gitlab-ci/default.yml b/.gitlab-ci/default.yml
index 7248d1eab9341067a8a80a9fe2eda4b8437968c7..1ed08c03332c08c28783bd67ddf06b07585eeca7 100644
--- a/.gitlab-ci/default.yml
+++ b/.gitlab-ci/default.yml
@@ -213,7 +213,7 @@ test python:
         mv build-cmake/dune-env /dune/modules/dune-common/build-cmake/dune-env
       fi
     - |
-      if ([ ! -s changedfiles.txt ] || grep -q python "changedfiles.txt"); then
+      if ( [ -d "build-cmake/python" ] && ([ ! -s changedfiles.txt ] || grep -q python "changedfiles.txt")); then
         if [ ! -s changedfiles.txt ]; then
           echo "Skipping test selection: considering all Python tests."
         else