diff --git a/src/test/Makefile b/src/test/Makefile
index 1c5f4021e2adba08db4783fad7499b5700fd6b30..fb7d6770142127157874f5de7e9811fcf3c31bca 100644
--- a/src/test/Makefile
+++ b/src/test/Makefile
@@ -370,7 +370,6 @@ clean clobber: $(TESTS_BUILD)
 	$(RM) *.$(SYNC_EXT)
 	$(RM) $(FILE_MAX_DAX_DEVICES)
 	$(RM) envconfig.sh envconfig.py
-	$(RM) -r __pycache__ */__pycache__
 
 $(TESTS) $(OBJ_DEPS) $(LIBPMEMPOOL_DEPS) $(LIBPMEMPOOL_MOD_DEPS): $(TEST_DEPS)
 
diff --git a/src/test/testframework.py b/src/test/testframework.py
index 02a1264ebee761441c92be2fa7c4053ea453ee2d..3f1769acfe2999ee0f0617b5c9541606ce8de365 100644
--- a/src/test/testframework.py
+++ b/src/test/testframework.py
@@ -6,6 +6,11 @@
 
 import sys
 from os import path
+
+# Don't create cache files on the import of test modules.
+# Improvement using bytecode in python tf code is insignificant.
+# It is workaround for a pycache clobber issue in our tangled Makefiles.
+sys.dont_write_bytecode = True
 sys.path.insert(1, path.abspath(path.join(path.dirname(__file__), 'unittest')))
 
 # flake8 issues silenced: