Prevent random test failures in Python 3

After adding a new module to a directory, the importlib caches need to
be cleared (invalidated) in Python 3.