diff --git a/builds/runtimes/python-2.7.13 b/builds/runtimes/python-2.7.13
index 85af1a9e74606512769514404fa33718484a8ca5..3f34aad6c1015f4837314acb9f236e32a136d22f 100755
--- a/builds/runtimes/python-2.7.13
+++ b/builds/runtimes/python-2.7.13
@@ -13,3 +13,7 @@ cd src
 ./configure --prefix=$OUT_PREFIX  --enable-unicode=ucs4 --with-ensurepip=no
 make
 make install
+
+# Remove unneeded test directories, similar to the official Docker Python images:
+# https://github.com/docker-library/python
+find "${OUT_PREFIX}" \( -type d -a \( -name test -o -name tests \) \) -exec rm -rf '{}' +
diff --git a/builds/runtimes/python-3.6.2 b/builds/runtimes/python-3.6.2
index c4dd8dbbcf64c07ea60585d1070289cbcea2fb2f..d23d4913c9cbab2717c2a88d6dbc454fc92e853d 100755
--- a/builds/runtimes/python-3.6.2
+++ b/builds/runtimes/python-3.6.2
@@ -14,5 +14,8 @@ cd src
 make
 make install
 
-ln $OUT_PREFIX/bin/python3 $OUT_PREFIX/bin/python
+# Remove unneeded test directories, similar to the official Docker Python images:
+# https://github.com/docker-library/python
+find "${OUT_PREFIX}" \( -type d -a \( -name test -o -name tests \) \) -exec rm -rf '{}' +
 
+ln $OUT_PREFIX/bin/python3 $OUT_PREFIX/bin/python