tests/test-demandimport.py
branchstable
changeset 45211 fc8299319ffe
parent 44118 f81c17ec303c
child 46226 0826d684a1b5
equal deleted inserted replaced
45210:42202492a3b9 45211:fc8299319ffe
   230 from mercurial import util
   230 from mercurial import util
   231 
   231 
   232 # Unlike the import statement, __import__() function should not raise
   232 # Unlike the import statement, __import__() function should not raise
   233 # ImportError even if fromlist has an unknown item
   233 # ImportError even if fromlist has an unknown item
   234 # (see Python/import.c:import_module_level() and ensure_fromlist())
   234 # (see Python/import.c:import_module_level() and ensure_fromlist())
   235 assert 'zipfile' not in sys.modules
   235 assert 'ftplib' not in sys.modules
   236 zipfileimp = __import__('zipfile', globals(), locals(), ['unknownattr'])
   236 zipfileimp = __import__('ftplib', globals(), locals(), ['unknownattr'])
   237 assert f(zipfileimp) == "<module 'zipfile' from '?'>", f(zipfileimp)
   237 assert f(zipfileimp) == "<module 'ftplib' from '?'>", f(zipfileimp)
   238 assert not util.safehasattr(zipfileimp, 'unknownattr')
   238 assert not util.safehasattr(zipfileimp, 'unknownattr')