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