diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py --- a/Lib/test/test_imp.py +++ b/Lib/test/test_imp.py @@ -279,7 +279,10 @@ # see #18681 from html import parser del sys.modules['html'] - def cleanup(): del sys.modules['html.parser'] + def cleanup(): + for mod in list(sys.modules): + if mod.startswith('html.'): + del sys.modules[mod] self.addCleanup(cleanup) with self.assertRaisesRegex(ImportError, 'html'): imp.reload(parser)