diff --git a/Lib/test/libregrtest/utils.py b/Lib/test/libregrtest/utils.py index b5bbe0ef6596a7..f62184ad4fec6c 100644 --- a/Lib/test/libregrtest/utils.py +++ b/Lib/test/libregrtest/utils.py @@ -184,6 +184,15 @@ def clear_caches(): if stream is not None: stream.flush() + # Clear assorted module caches. + # Don't worry about resetting the cache if the module is not loaded + try: + distutils_dir_util = sys.modules['distutils.dir_util'] + except KeyError: + pass + else: + distutils_dir_util._path_created.clear() + try: re = sys.modules['re'] except KeyError: