test-demandimport.py
62 lines
| 1.3 KiB
| text/x-python
|
PythonLexer
/ tests / test-demandimport.py
|
r28948 | from __future__ import print_function | ||
|
r8449 | from mercurial import demandimport | ||
demandimport.enable() | ||||
|
r23643 | import os | ||
if os.name != 'nt': | ||||
try: | ||||
import distutils.msvc9compiler | ||||
|
r28948 | print('distutils.msvc9compiler needs to be an immediate ' | ||
'importerror on non-windows platforms') | ||||
|
r23643 | distutils.msvc9compiler | ||
except ImportError: | ||||
pass | ||||
|
r8449 | import re | ||
rsub = re.sub | ||||
def f(obj): | ||||
l = repr(obj) | ||||
l = rsub("0x[0-9a-fA-F]+", "0x?", l) | ||||
l = rsub("from '.*'", "from '?'", l) | ||||
|
r13083 | l = rsub("'<[a-z]*>'", "'<whatever>'", l) | ||
|
r8449 | return l | ||
import os | ||||
|
r28948 | print("os =", f(os)) | ||
print("os.system =", f(os.system)) | ||||
print("os =", f(os)) | ||||
|
r8449 | |||
from mercurial import util | ||||
|
r28948 | print("util =", f(util)) | ||
print("util.system =", f(util.system)) | ||||
print("util =", f(util)) | ||||
print("util.system =", f(util.system)) | ||||
|
r8449 | |||
|
r27535 | from mercurial import hgweb | ||
|
r28948 | print("hgweb =", f(hgweb)) | ||
print("hgweb_mod =", f(hgweb.hgweb_mod)) | ||||
print("hgweb =", f(hgweb)) | ||||
|
r27535 | |||
|
r8449 | import re as fred | ||
|
r28948 | print("fred =", f(fred)) | ||
|
r8449 | |||
import sys as re | ||||
|
r28948 | print("re =", f(re)) | ||
|
r8449 | |||
|
r28948 | print("fred =", f(fred)) | ||
print("fred.sub =", f(fred.sub)) | ||||
print("fred =", f(fred)) | ||||
|
r8449 | |||
|
r28948 | print("re =", f(re)) | ||
print("re.stderr =", f(re.stderr)) | ||||
print("re =", f(re)) | ||||
|
r21025 | |||
demandimport.disable() | ||||
os.environ['HGDEMANDIMPORT'] = 'disable' | ||||
demandimport.enable() | ||||
from mercurial import node | ||||
|
r28948 | print("node =", f(node)) | ||