##// END OF EJS Templates
test-demandimport: ensure that relative imports are deferred...
Bryan O'Sullivan -
r27535:0d0f4070 default
parent child Browse files
Show More
@@ -1,55 +1,60
1 from mercurial import demandimport
1 from mercurial import demandimport
2 demandimport.enable()
2 demandimport.enable()
3
3
4 import os
4 import os
5 if os.name != 'nt':
5 if os.name != 'nt':
6 try:
6 try:
7 import distutils.msvc9compiler
7 import distutils.msvc9compiler
8 print ('distutils.msvc9compiler needs to be an immediate '
8 print ('distutils.msvc9compiler needs to be an immediate '
9 'importerror on non-windows platforms')
9 'importerror on non-windows platforms')
10 distutils.msvc9compiler
10 distutils.msvc9compiler
11 except ImportError:
11 except ImportError:
12 pass
12 pass
13
13
14 import re
14 import re
15
15
16 rsub = re.sub
16 rsub = re.sub
17 def f(obj):
17 def f(obj):
18 l = repr(obj)
18 l = repr(obj)
19 l = rsub("0x[0-9a-fA-F]+", "0x?", l)
19 l = rsub("0x[0-9a-fA-F]+", "0x?", l)
20 l = rsub("from '.*'", "from '?'", l)
20 l = rsub("from '.*'", "from '?'", l)
21 l = rsub("'<[a-z]*>'", "'<whatever>'", l)
21 l = rsub("'<[a-z]*>'", "'<whatever>'", l)
22 return l
22 return l
23
23
24 import os
24 import os
25
25
26 print "os =", f(os)
26 print "os =", f(os)
27 print "os.system =", f(os.system)
27 print "os.system =", f(os.system)
28 print "os =", f(os)
28 print "os =", f(os)
29
29
30 from mercurial import util
30 from mercurial import util
31
31
32 print "util =", f(util)
32 print "util =", f(util)
33 print "util.system =", f(util.system)
33 print "util.system =", f(util.system)
34 print "util =", f(util)
34 print "util =", f(util)
35 print "util.system =", f(util.system)
35 print "util.system =", f(util.system)
36
36
37 from mercurial import hgweb
38 print "hgweb =", f(hgweb)
39 print "hgweb_mod =", f(hgweb.hgweb_mod)
40 print "hgweb =", f(hgweb)
41
37 import re as fred
42 import re as fred
38 print "fred =", f(fred)
43 print "fred =", f(fred)
39
44
40 import sys as re
45 import sys as re
41 print "re =", f(re)
46 print "re =", f(re)
42
47
43 print "fred =", f(fred)
48 print "fred =", f(fred)
44 print "fred.sub =", f(fred.sub)
49 print "fred.sub =", f(fred.sub)
45 print "fred =", f(fred)
50 print "fred =", f(fred)
46
51
47 print "re =", f(re)
52 print "re =", f(re)
48 print "re.stderr =", f(re.stderr)
53 print "re.stderr =", f(re.stderr)
49 print "re =", f(re)
54 print "re =", f(re)
50
55
51 demandimport.disable()
56 demandimport.disable()
52 os.environ['HGDEMANDIMPORT'] = 'disable'
57 os.environ['HGDEMANDIMPORT'] = 'disable'
53 demandimport.enable()
58 demandimport.enable()
54 from mercurial import node
59 from mercurial import node
55 print "node =", f(node)
60 print "node =", f(node)
@@ -1,16 +1,19
1 os = <unloaded module 'os'>
1 os = <unloaded module 'os'>
2 os.system = <built-in function system>
2 os.system = <built-in function system>
3 os = <module 'os' from '?'>
3 os = <module 'os' from '?'>
4 util = <unloaded module 'util'>
4 util = <unloaded module 'util'>
5 util.system = <function system at 0x?>
5 util.system = <function system at 0x?>
6 util = <module 'mercurial.util' from '?'>
6 util = <module 'mercurial.util' from '?'>
7 util.system = <function system at 0x?>
7 util.system = <function system at 0x?>
8 hgweb = <unloaded module 'hgweb'>
9 hgweb_mod = <unloaded module 'hgweb_mod'>
10 hgweb = <module 'mercurial.hgweb' from '?'>
8 fred = <unloaded module 're'>
11 fred = <unloaded module 're'>
9 re = <unloaded module 'sys'>
12 re = <unloaded module 'sys'>
10 fred = <unloaded module 're'>
13 fred = <unloaded module 're'>
11 fred.sub = <function sub at 0x?>
14 fred.sub = <function sub at 0x?>
12 fred = <proxied module 're'>
15 fred = <proxied module 're'>
13 re = <unloaded module 'sys'>
16 re = <unloaded module 'sys'>
14 re.stderr = <open file '<whatever>', mode 'w' at 0x?>
17 re.stderr = <open file '<whatever>', mode 'w' at 0x?>
15 re = <proxied module 'sys'>
18 re = <proxied module 'sys'>
16 node = <module 'mercurial.node' from '?'>
19 node = <module 'mercurial.node' from '?'>
General Comments 0
You need to be logged in to leave comments. Login now