Show More
@@ -1,47 +1,46 | |||
|
1 | 1 | #require test-repo |
|
2 | 2 | |
|
3 | 3 | $ . "$TESTDIR/helpers-testrepo.sh" |
|
4 | 4 | $ cd "$TESTDIR"/.. |
|
5 | 5 | |
|
6 | 6 | $ testrepohg files 'set:(**.py)' \ |
|
7 | 7 | > -X hgdemandimport/demandimportpy2.py \ |
|
8 | 8 | > | sed 's|\\|/|g' | xargs $PYTHON contrib/check-py3-compat.py |
|
9 | 9 | contrib/python-zstandard/setup.py not using absolute_import |
|
10 | 10 | contrib/python-zstandard/setup_zstd.py not using absolute_import |
|
11 | 11 | contrib/python-zstandard/tests/common.py not using absolute_import |
|
12 | 12 | contrib/python-zstandard/tests/test_buffer_util.py not using absolute_import |
|
13 | 13 | contrib/python-zstandard/tests/test_compressor.py not using absolute_import |
|
14 | 14 | contrib/python-zstandard/tests/test_compressor_fuzzing.py not using absolute_import |
|
15 | 15 | contrib/python-zstandard/tests/test_data_structures.py not using absolute_import |
|
16 | 16 | contrib/python-zstandard/tests/test_data_structures_fuzzing.py not using absolute_import |
|
17 | 17 | contrib/python-zstandard/tests/test_decompressor.py not using absolute_import |
|
18 | 18 | contrib/python-zstandard/tests/test_decompressor_fuzzing.py not using absolute_import |
|
19 | 19 | contrib/python-zstandard/tests/test_estimate_sizes.py not using absolute_import |
|
20 | 20 | contrib/python-zstandard/tests/test_module_attributes.py not using absolute_import |
|
21 | 21 | contrib/python-zstandard/tests/test_train_dictionary.py not using absolute_import |
|
22 | 22 | setup.py not using absolute_import |
|
23 | tests/test-demandimport.py not using absolute_import | |
|
24 | 23 | |
|
25 | 24 | #if py3exe |
|
26 | 25 | $ testrepohg files 'set:(**.py) - grep(pygments)' \ |
|
27 | 26 | > -X hgdemandimport/demandimportpy2.py \ |
|
28 | 27 | > -X hgext/fsmonitor/pywatchman \ |
|
29 | 28 | > | sed 's|\\|/|g' | xargs $PYTHON3 contrib/check-py3-compat.py \ |
|
30 | 29 | > | sed 's/[0-9][0-9]*)$/*)/' |
|
31 | 30 | hgext/convert/transport.py: error importing: <*Error> No module named 'svn.client' (error at transport.py:*) (glob) |
|
32 | 31 | mercurial/cffi/bdiff.py: error importing: <ImportError> cannot import name '_bdiff' (error at bdiff.py:*) |
|
33 | 32 | mercurial/cffi/bdiffbuild.py: error importing: <ImportError> No module named 'cffi' (error at bdiffbuild.py:*) |
|
34 | 33 | mercurial/cffi/mpatch.py: error importing: <ImportError> cannot import name '_mpatch' (error at mpatch.py:*) |
|
35 | 34 | mercurial/cffi/mpatchbuild.py: error importing: <ImportError> No module named 'cffi' (error at mpatchbuild.py:*) |
|
36 | 35 | mercurial/cffi/osutilbuild.py: error importing: <ImportError> No module named 'cffi' (error at osutilbuild.py:*) |
|
37 | 36 | mercurial/scmwindows.py: error importing: <*Error> No module named 'msvcrt' (error at win32.py:*) (glob) |
|
38 | 37 | mercurial/win32.py: error importing: <*Error> No module named 'msvcrt' (error at win32.py:*) (glob) |
|
39 | 38 | mercurial/windows.py: error importing: <*Error> No module named 'msvcrt' (error at windows.py:*) (glob) |
|
40 | 39 | |
|
41 | 40 | #endif |
|
42 | 41 | |
|
43 | 42 | #if py3exe py3pygments |
|
44 | 43 | $ testrepohg files 'set:(**.py) and grep(pygments)' | sed 's|\\|/|g' \ |
|
45 | 44 | > | xargs $PYTHON3 contrib/check-py3-compat.py \ |
|
46 | 45 | > | sed 's/[0-9][0-9]*)$/*)/' |
|
47 | 46 | #endif |
@@ -1,106 +1,106 | |||
|
1 | from __future__ import print_function | |
|
1 | from __future__ import absolute_import, print_function | |
|
2 | 2 | |
|
3 | 3 | from mercurial import demandimport |
|
4 | 4 | demandimport.enable() |
|
5 | 5 | |
|
6 | 6 | import os |
|
7 | 7 | import subprocess |
|
8 | 8 | import sys |
|
9 | 9 | |
|
10 | 10 | # Only run if demandimport is allowed |
|
11 | 11 | if subprocess.call(['python', '%s/hghave' % os.environ['TESTDIR'], |
|
12 | 12 | 'demandimport']): |
|
13 | 13 | sys.exit(80) |
|
14 | 14 | |
|
15 | 15 | if os.name != 'nt': |
|
16 | 16 | try: |
|
17 | 17 | import distutils.msvc9compiler |
|
18 | 18 | print('distutils.msvc9compiler needs to be an immediate ' |
|
19 | 19 | 'importerror on non-windows platforms') |
|
20 | 20 | distutils.msvc9compiler |
|
21 | 21 | except ImportError: |
|
22 | 22 | pass |
|
23 | 23 | |
|
24 | 24 | import re |
|
25 | 25 | |
|
26 | 26 | rsub = re.sub |
|
27 | 27 | def f(obj): |
|
28 | 28 | l = repr(obj) |
|
29 | 29 | l = rsub("0x[0-9a-fA-F]+", "0x?", l) |
|
30 | 30 | l = rsub("from '.*'", "from '?'", l) |
|
31 | 31 | l = rsub("'<[a-z]*>'", "'<whatever>'", l) |
|
32 | 32 | return l |
|
33 | 33 | |
|
34 | 34 | import os |
|
35 | 35 | |
|
36 | 36 | print("os =", f(os)) |
|
37 | 37 | print("os.system =", f(os.system)) |
|
38 | 38 | print("os =", f(os)) |
|
39 | 39 | |
|
40 | 40 | from mercurial import util |
|
41 | 41 | |
|
42 | 42 | print("util =", f(util)) |
|
43 | 43 | print("util.system =", f(util.system)) |
|
44 | 44 | print("util =", f(util)) |
|
45 | 45 | print("util.system =", f(util.system)) |
|
46 | 46 | |
|
47 | 47 | from mercurial import hgweb |
|
48 | 48 | print("hgweb =", f(hgweb)) |
|
49 | 49 | print("hgweb_mod =", f(hgweb.hgweb_mod)) |
|
50 | 50 | print("hgweb =", f(hgweb)) |
|
51 | 51 | |
|
52 | 52 | import re as fred |
|
53 | 53 | print("fred =", f(fred)) |
|
54 | 54 | |
|
55 | 55 | import re as remod |
|
56 | 56 | print("remod =", f(remod)) |
|
57 | 57 | |
|
58 | 58 | import sys as re |
|
59 | 59 | print("re =", f(re)) |
|
60 | 60 | |
|
61 | 61 | print("fred =", f(fred)) |
|
62 | 62 | print("fred.sub =", f(fred.sub)) |
|
63 | 63 | print("fred =", f(fred)) |
|
64 | 64 | |
|
65 | 65 | remod.escape # use remod |
|
66 | 66 | print("remod =", f(remod)) |
|
67 | 67 | |
|
68 | 68 | print("re =", f(re)) |
|
69 | 69 | print("re.stderr =", f(re.stderr)) |
|
70 | 70 | print("re =", f(re)) |
|
71 | 71 | |
|
72 | 72 | # Test access to special attributes through demandmod proxy |
|
73 | 73 | from mercurial import pvec as pvecproxy |
|
74 | 74 | print("pvecproxy =", f(pvecproxy)) |
|
75 | 75 | print("pvecproxy.__doc__ = %r" |
|
76 | 76 | % (' '.join(pvecproxy.__doc__.split()[:3]) + ' ...')) |
|
77 | 77 | print("pvecproxy.__name__ = %r" % pvecproxy.__name__) |
|
78 | 78 | # __name__ must be accessible via __dict__ so the relative imports can be |
|
79 | 79 | # resolved |
|
80 | 80 | print("pvecproxy.__dict__['__name__'] = %r" % pvecproxy.__dict__['__name__']) |
|
81 | 81 | print("pvecproxy =", f(pvecproxy)) |
|
82 | 82 | |
|
83 | 83 | import contextlib |
|
84 | 84 | print("contextlib =", f(contextlib)) |
|
85 | 85 | try: |
|
86 | 86 | from contextlib import unknownattr |
|
87 | 87 | print('no demandmod should be created for attribute of non-package ' |
|
88 | 88 | 'module:\ncontextlib.unknownattr =', f(unknownattr)) |
|
89 | 89 | except ImportError as inst: |
|
90 | 90 | print('contextlib.unknownattr = ImportError: %s' |
|
91 | 91 | % rsub(r"'", '', str(inst))) |
|
92 | 92 | |
|
93 | 93 | # Unlike the import statement, __import__() function should not raise |
|
94 | 94 | # ImportError even if fromlist has an unknown item |
|
95 | 95 | # (see Python/import.c:import_module_level() and ensure_fromlist()) |
|
96 | 96 | contextlibimp = __import__('contextlib', globals(), locals(), ['unknownattr']) |
|
97 | 97 | print("__import__('contextlib', ..., ['unknownattr']) =", f(contextlibimp)) |
|
98 | 98 | print("hasattr(contextlibimp, 'unknownattr') =", |
|
99 | 99 | util.safehasattr(contextlibimp, 'unknownattr')) |
|
100 | 100 | |
|
101 | 101 | demandimport.disable() |
|
102 | 102 | os.environ['HGDEMANDIMPORT'] = 'disable' |
|
103 | 103 | # this enable call should not actually enable demandimport! |
|
104 | 104 | demandimport.enable() |
|
105 | 105 | from mercurial import node |
|
106 | 106 | print("node =", f(node)) |
General Comments 0
You need to be logged in to leave comments.
Login now