Mercurial > public > mercurial-scm > hg
comparison tests/test-demandimport.py @ 30022:26a4e46af2bc
demandimport: error out early on missing attribute of non package (issue5373)
If the parent module isn't a package, all valid attributes must be obtained
from it. We can raise ImportError early if any attributes not found.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 26 Sep 2016 23:28:57 +0900 |
parents | 129e38a76f2c |
children | 1914db1b7d9e |
comparison
equal
deleted
inserted
replaced
30021:16a09ae318b4 | 30022:26a4e46af2bc |
---|---|
61 | 61 |
62 print("re =", f(re)) | 62 print("re =", f(re)) |
63 print("re.stderr =", f(re.stderr)) | 63 print("re.stderr =", f(re.stderr)) |
64 print("re =", f(re)) | 64 print("re =", f(re)) |
65 | 65 |
66 import contextlib | |
67 print("contextlib =", f(contextlib)) | |
68 try: | |
69 from contextlib import unknownattr | |
70 print('no demandmod should be created for attribute of non-package ' | |
71 'module:\ncontextlib.unknownattr =', f(unknownattr)) | |
72 except ImportError as inst: | |
73 print('contextlib.unknownattr = ImportError: %s' % inst) | |
74 | |
66 demandimport.disable() | 75 demandimport.disable() |
67 os.environ['HGDEMANDIMPORT'] = 'disable' | 76 os.environ['HGDEMANDIMPORT'] = 'disable' |
68 # this enable call should not actually enable demandimport! | 77 # this enable call should not actually enable demandimport! |
69 demandimport.enable() | 78 demandimport.enable() |
70 from mercurial import node | 79 from mercurial import node |