# HG changeset patch # User Martin von Zweigbergk # Date 1518809636 28800 # Node ID c2c5f9f6fa215d2b501e71b74602e0e7aa3ca1a8 # Parent 4174970c91478d5db4814fcdcf17a616bb4f2fa9 tests: avoid referring to pvec in demandimport test Nothing else currently uses pvec, so we may want to delete it (but Augie Fackler says he may want to use it). To enable deletion, this patch replaces it by the error module in the demandimport test (any module works). However, since the error module had already been loaded at this point in the test (via the util module), I moved it earlier in the test so it's still not loaded (although I'm not sure if that's even relevant to the test). Differential Revision: https://phab.mercurial-scm.org/D2287 diff -r 4174970c9147 -r c2c5f9f6fa21 tests/test-demandimport.py --- a/tests/test-demandimport.py Mon Jan 08 12:09:43 2018 +0900 +++ b/tests/test-demandimport.py Fri Feb 16 11:33:56 2018 -0800 @@ -41,6 +41,17 @@ del os.environ['HGDEMANDIMPORT'] demandimport.enable() +# Test access to special attributes through demandmod proxy +from mercurial import error as errorproxy +print("errorproxy =", f(errorproxy)) +print("errorproxy.__doc__ = %r" + % (' '.join(errorproxy.__doc__.split()[:3]) + ' ...')) +print("errorproxy.__name__ = %r" % errorproxy.__name__) +# __name__ must be accessible via __dict__ so the relative imports can be +# resolved +print("errorproxy.__dict__['__name__'] = %r" % errorproxy.__dict__['__name__']) +print("errorproxy =", f(errorproxy)) + import os print("os =", f(os)) @@ -79,17 +90,6 @@ print("re.stderr =", f(re.stderr)) print("re =", f(re)) -# Test access to special attributes through demandmod proxy -from mercurial import pvec as pvecproxy -print("pvecproxy =", f(pvecproxy)) -print("pvecproxy.__doc__ = %r" - % (' '.join(pvecproxy.__doc__.split()[:3]) + ' ...')) -print("pvecproxy.__name__ = %r" % pvecproxy.__name__) -# __name__ must be accessible via __dict__ so the relative imports can be -# resolved -print("pvecproxy.__dict__['__name__'] = %r" % pvecproxy.__dict__['__name__']) -print("pvecproxy =", f(pvecproxy)) - import contextlib print("contextlib =", f(contextlib)) try: diff -r 4174970c9147 -r c2c5f9f6fa21 tests/test-demandimport.py.out --- a/tests/test-demandimport.py.out Mon Jan 08 12:09:43 2018 +0900 +++ b/tests/test-demandimport.py.out Fri Feb 16 11:33:56 2018 -0800 @@ -1,4 +1,9 @@ node = +errorproxy = +errorproxy.__doc__ = 'Mercurial exceptions. This ...' +errorproxy.__name__ = 'mercurial.error' +errorproxy.__dict__['__name__'] = 'mercurial.error' +errorproxy = os = os.system = os = @@ -19,11 +24,6 @@ re = re.stderr = ', mode 'w' at 0x?> re = -pvecproxy = -pvecproxy.__doc__ = 'A "pvec" is ...' -pvecproxy.__name__ = 'mercurial.pvec' -pvecproxy.__dict__['__name__'] = 'mercurial.pvec' -pvecproxy = contextlib = contextlib.unknownattr = ImportError: cannot import name unknownattr __import__('contextlib', ..., ['unknownattr']) =