changeset 41522:b0865b5919c6

py3: account for demand import difference between Python versions Our lazy importer for Python 3 will validate that modules are loadable before returning a stub module object. This is different from Python 2, which will always return a stub module object. While we could change behavior of the Python 3 demand importer, that seems like a problem for another day. This commit teaches test-extension.t about that difference in behavior. Differential Revision: https://phab.mercurial-scm.org/D5798
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 01 Feb 2019 17:03:51 -0800
parents 30248d6bc057
children 11c076786d56
files tests/test-extension.t
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-extension.t	Fri Feb 01 13:20:13 2019 -0800
+++ b/tests/test-extension.t	Fri Feb 01 17:03:51 2019 -0800
@@ -610,7 +610,8 @@
   > cmdtable = {}
   > command = registrar.command(cmdtable)
   > 
-  > # demand import avoids failure of importing notexist here
+  > # demand import avoids failure of importing notexist here, but only on
+  > # Python 2.
   > import extlibroot.lsub1.lsub2.notexist
   > 
   > @command(b'checkrelativity', [], norepo=True)
@@ -622,7 +623,13 @@
   >         pass # intentional failure
   > NO_CHECK_EOF
 
-  $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.checkrelativity=$TESTTMP/checkrelativity.py checkrelativity)
+Python 3's lazy importer verifies modules exist before returning the lazy
+module stub. Our custom lazy importer for Python 2 always returns a stub.
+
+  $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.checkrelativity=$TESTTMP/checkrelativity.py checkrelativity) || true
+  *** failed to import extension checkrelativity from $TESTTMP/checkrelativity.py: No module named 'extlibroot.lsub1.lsub2.notexist' (py3 !)
+  hg: unknown command 'checkrelativity' (py3 !)
+  (use 'hg help' for a list of commands) (py3 !)
 
 #endif