changeset 45396:fc8299319ffe stable

tests: fix test-demandimport.py on Python 3.9 Starting with Python 3.9, importing importlib.resources (indirectly) imports the zipfile module. Therefore, the module is not suitable for the test. Instead, we can use the ftplib module, which is very unlikely to be imported during the test run.
author Manuel Jacob <me@manueljacob.de>
date Wed, 02 Sep 2020 01:30:56 +0200
parents 42202492a3b9
children 148d177a4f2d
files tests/test-demandimport.py
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-demandimport.py	Tue Sep 01 16:27:25 2020 +0530
+++ b/tests/test-demandimport.py	Wed Sep 02 01:30:56 2020 +0200
@@ -232,7 +232,7 @@
 # Unlike the import statement, __import__() function should not raise
 # ImportError even if fromlist has an unknown item
 # (see Python/import.c:import_module_level() and ensure_fromlist())
-assert 'zipfile' not in sys.modules
-zipfileimp = __import__('zipfile', globals(), locals(), ['unknownattr'])
-assert f(zipfileimp) == "<module 'zipfile' from '?'>", f(zipfileimp)
+assert 'ftplib' not in sys.modules
+zipfileimp = __import__('ftplib', globals(), locals(), ['unknownattr'])
+assert f(zipfileimp) == "<module 'ftplib' from '?'>", f(zipfileimp)
 assert not util.safehasattr(zipfileimp, 'unknownattr')