equal
deleted
inserted
replaced
608 $ cat > $TESTTMP/checkrelativity.py <<NO_CHECK_EOF |
608 $ cat > $TESTTMP/checkrelativity.py <<NO_CHECK_EOF |
609 > from mercurial import registrar |
609 > from mercurial import registrar |
610 > cmdtable = {} |
610 > cmdtable = {} |
611 > command = registrar.command(cmdtable) |
611 > command = registrar.command(cmdtable) |
612 > |
612 > |
613 > # demand import avoids failure of importing notexist here |
613 > # demand import avoids failure of importing notexist here, but only on |
|
614 > # Python 2. |
614 > import extlibroot.lsub1.lsub2.notexist |
615 > import extlibroot.lsub1.lsub2.notexist |
615 > |
616 > |
616 > @command(b'checkrelativity', [], norepo=True) |
617 > @command(b'checkrelativity', [], norepo=True) |
617 > def checkrelativity(ui, *args, **opts): |
618 > def checkrelativity(ui, *args, **opts): |
618 > try: |
619 > try: |
620 > return 1 # unintentional success |
621 > return 1 # unintentional success |
621 > except ImportError: |
622 > except ImportError: |
622 > pass # intentional failure |
623 > pass # intentional failure |
623 > NO_CHECK_EOF |
624 > NO_CHECK_EOF |
624 |
625 |
625 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.checkrelativity=$TESTTMP/checkrelativity.py checkrelativity) |
626 Python 3's lazy importer verifies modules exist before returning the lazy |
|
627 module stub. Our custom lazy importer for Python 2 always returns a stub. |
|
628 |
|
629 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.checkrelativity=$TESTTMP/checkrelativity.py checkrelativity) || true |
|
630 *** failed to import extension checkrelativity from $TESTTMP/checkrelativity.py: No module named 'extlibroot.lsub1.lsub2.notexist' (py3 !) |
|
631 hg: unknown command 'checkrelativity' (py3 !) |
|
632 (use 'hg help' for a list of commands) (py3 !) |
626 |
633 |
627 #endif |
634 #endif |
628 |
635 |
629 (Here, module importing tests are finished. Therefore, use other than |
636 (Here, module importing tests are finished. Therefore, use other than |
630 NO_CHECK_* limit mark for heredoc python files, in order to apply |
637 NO_CHECK_* limit mark for heredoc python files, in order to apply |