Running a test suite can cause python to write out bytecode files which can cause issues. In order to prevent this, %py_test should either pass -B to the interpreter or export PYTHONDONTWRITEBYTECODE=1.