cleanup: use $PYTHON to run python in many more tests
authorAugie Fackler <augie@google.com>
Tue, 20 Jun 2017 09:45:02 -0400
changeset 32940 75be14993fda
parent 32939 cad62cb3c84c
child 32941 20ed0e6a4905
cleanup: use $PYTHON to run python in many more tests Spotted one of these, then wrote a check-code rule that caught them all. It will be the next change.
tests/test-addremove-similar.t
tests/test-archive.t
tests/test-bad-pull.t
tests/test-basic.t
tests/test-bisect.t
tests/test-blackbox.t
tests/test-bookmarks-pushpull.t
tests/test-bundle2-remote-changegroup.t
tests/test-censor.t
tests/test-check-config.t
tests/test-check-help.t
tests/test-check-py3-compat.t
tests/test-chg.t
tests/test-clone-cgi.t
tests/test-clone.t
tests/test-clonebundles.t
tests/test-commit-interactive.t
tests/test-convert-bzr-ghosts.t
tests/test-convert-bzr-treeroot.t
tests/test-convert-bzr.t
tests/test-convert-clonebranches.t
tests/test-convert-hg-source.t
tests/test-convert-svn-sink.t
tests/test-debugcommands.t
tests/test-diff-binary-file.t
tests/test-eol.t
tests/test-fileset-generated.t
tests/test-gendoc.t
tests/test-hardlinks.t
tests/test-help.t
tests/test-hgignore.t
tests/test-hgweb-no-path-info.t
tests/test-hgweb-no-request-uri.t
tests/test-hgweb-non-interactive.t
tests/test-i18n.t
tests/test-impexp-branch.t
tests/test-import-context.t
tests/test-import-eol.t
tests/test-import.t
tests/test-imports-checker.t
tests/test-inherit-mode.t
tests/test-install.t
tests/test-issue4074.t
tests/test-mactext.t
tests/test-merge-force.t
tests/test-merge-symlinks.t
tests/test-mq-eol.t
tests/test-mq-missingfiles.t
tests/test-mq-qimport.t
tests/test-mq.t
tests/test-pager-legacy.t
tests/test-pager.t
tests/test-parseindex.t
tests/test-patch-offset.t
tests/test-patch.t
tests/test-patchbomb-tls.t
tests/test-patchbomb.t
tests/test-push-warn.t
tests/test-relink.t
tests/test-repair-strip.t
tests/test-revert.t
tests/test-setdiscovery.t
tests/test-simple-update.t
tests/test-static-http.t
tests/test-status-rev.t
tests/test-tools.t
tests/test-win32text.t
--- a/tests/test-addremove-similar.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-addremove-similar.t	Tue Jun 20 09:45:02 2017 -0400
@@ -57,7 +57,7 @@
 
 should be sorted by path for stable result
 
-  $ for i in `python $TESTDIR/seq.py 0 9`; do
+  $ for i in `$PYTHON $TESTDIR/seq.py 0 9`; do
   >     cp small-file $i
   > done
   $ rm small-file
@@ -88,7 +88,7 @@
 pick one from many identical files
 
   $ cp 0 a
-  $ rm `python $TESTDIR/seq.py 0 9`
+  $ rm `$PYTHON $TESTDIR/seq.py 0 9`
   $ hg addremove
   removing 0
   removing 1
@@ -107,11 +107,11 @@
 pick one from many similar files
 
   $ cp 0 a
-  $ for i in `python $TESTDIR/seq.py 0 9`; do
+  $ for i in `$PYTHON $TESTDIR/seq.py 0 9`; do
   >     echo $i >> $i
   > done
   $ hg commit -m 'make them slightly different'
-  $ rm `python $TESTDIR/seq.py 0 9`
+  $ rm `$PYTHON $TESTDIR/seq.py 0 9`
   $ hg addremove -s50
   removing 0
   removing 1
--- a/tests/test-archive.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-archive.t	Tue Jun 20 09:45:02 2017 -0400
@@ -105,7 +105,7 @@
   > except util.urlerr.httperror as e:
   >     sys.stderr.write(str(e) + '\n')
   > EOF
-  $ python getarchive.py "$TIP" gz | gunzip | tar tf - 2>/dev/null
+  $ $PYTHON getarchive.py "$TIP" gz | gunzip | tar tf - 2>/dev/null
   test-archive-1701ef1f1510/.hg_archival.txt
   test-archive-1701ef1f1510/.hgsub
   test-archive-1701ef1f1510/.hgsubstate
@@ -113,7 +113,7 @@
   test-archive-1701ef1f1510/baz/bletch
   test-archive-1701ef1f1510/foo
   test-archive-1701ef1f1510/subrepo/sub
-  $ python getarchive.py "$TIP" bz2 | bunzip2 | tar tf - 2>/dev/null
+  $ $PYTHON getarchive.py "$TIP" bz2 | bunzip2 | tar tf - 2>/dev/null
   test-archive-1701ef1f1510/.hg_archival.txt
   test-archive-1701ef1f1510/.hgsub
   test-archive-1701ef1f1510/.hgsubstate
@@ -121,7 +121,7 @@
   test-archive-1701ef1f1510/baz/bletch
   test-archive-1701ef1f1510/foo
   test-archive-1701ef1f1510/subrepo/sub
-  $ python getarchive.py "$TIP" zip > archive.zip
+  $ $PYTHON getarchive.py "$TIP" zip > archive.zip
   $ unzip -t archive.zip
   Archive:  archive.zip
       testing: test-archive-1701ef1f1510/.hg_archival.txt*OK (glob)
@@ -135,19 +135,19 @@
 
 test that we can download single directories and files
 
-  $ python getarchive.py "$TIP" gz baz | gunzip | tar tf - 2>/dev/null
+  $ $PYTHON getarchive.py "$TIP" gz baz | gunzip | tar tf - 2>/dev/null
   test-archive-1701ef1f1510/baz/bletch
-  $ python getarchive.py "$TIP" gz foo | gunzip | tar tf - 2>/dev/null
+  $ $PYTHON getarchive.py "$TIP" gz foo | gunzip | tar tf - 2>/dev/null
   test-archive-1701ef1f1510/foo
 
 test that we detect file patterns that match no files
 
-  $ python getarchive.py "$TIP" gz foobar
+  $ $PYTHON getarchive.py "$TIP" gz foobar
   HTTP Error 404: file(s) not found: foobar
 
 test that we reject unsafe patterns
 
-  $ python getarchive.py "$TIP" gz relre:baz
+  $ $PYTHON getarchive.py "$TIP" gz relre:baz
   HTTP Error 404: file(s) not found: relre:baz
 
   $ killdaemons.py
@@ -231,7 +231,7 @@
   $ sleep 1
   $ hg archive -t tgz tip.tar.gz
   $ mv tip.tar.gz tip2.tar.gz
-  $ python md5comp.py tip1.tar.gz tip2.tar.gz
+  $ $PYTHON md5comp.py tip1.tar.gz tip2.tar.gz
   True
 
   $ hg archive -t zip -p /illegal test.zip
@@ -364,12 +364,12 @@
 
   $ hg -R repo archive --prefix tar-extracted archive.tar
   $ (TZ=UTC-3; export TZ; tar xf archive.tar)
-  $ python show_mtime.py tar-extracted/a
+  $ $PYTHON show_mtime.py tar-extracted/a
   456789012
 
   $ hg -R repo archive --prefix zip-extracted archive.zip
   $ (TZ=UTC-3; export TZ; unzip -q archive.zip)
-  $ python show_mtime.py zip-extracted/a
+  $ $PYTHON show_mtime.py zip-extracted/a
   456789012
 
   $ cd ..
--- a/tests/test-bad-pull.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-bad-pull.t	Tue Jun 20 09:45:02 2017 -0400
@@ -7,7 +7,7 @@
   $ test -d copy
   [1]
 
-  $ python "$TESTDIR/dumbhttp.py" -p $HGPORT --pid dumb.pid
+  $ $PYTHON "$TESTDIR/dumbhttp.py" -p $HGPORT --pid dumb.pid
   $ cat dumb.pid >> $DAEMON_PIDS
   $ hg clone http://localhost:$HGPORT/foo copy2
   abort: HTTP Error 404: * (glob)
--- a/tests/test-basic.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-basic.t	Tue Jun 20 09:45:02 2017 -0400
@@ -60,7 +60,7 @@
   > EOF
   $ hg up null
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  $ python ./update_to_rev0.py
+  $ $PYTHON ./update_to_rev0.py
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg identify -n
   0
--- a/tests/test-bisect.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-bisect.t	Tue Jun 20 09:45:02 2017 -0400
@@ -463,12 +463,12 @@
   $ chmod +x script.py
   $ hg bisect -r
   $ hg up -qr tip
-  $ hg bisect --command "python \"$TESTTMP/script.py\" and some parameters"
+  $ hg bisect --command "$PYTHON \"$TESTTMP/script.py\" and some parameters"
   changeset 31:58c80a7c8a40: good
   abort: cannot bisect (no known bad revisions)
   [255]
   $ hg up -qr 0
-  $ hg bisect --command "python \"$TESTTMP/script.py\" and some parameters"
+  $ hg bisect --command "$PYTHON \"$TESTTMP/script.py\" and some parameters"
   changeset 0:b99c7b9c8e11: bad
   changeset 15:e7fa0811edb0: good
   changeset 7:03750880c6b5: good
--- a/tests/test-blackbox.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-blackbox.t	Tue Jun 20 09:45:02 2017 -0400
@@ -172,7 +172,7 @@
   $ sed -e 's/\(.*test1.*\)/#\1/; s#\(.*commit2.*\)#os.rmdir(".hg/blackbox.log")\
   > os.rename(".hg/blackbox.log-", ".hg/blackbox.log")\
   > \1#' $TESTDIR/test-dispatch.py > ../test-dispatch.py
-  $ python $TESTDIR/blackbox-readonly-dispatch.py
+  $ $PYTHON $TESTDIR/blackbox-readonly-dispatch.py
   running: add foo
   result: 0
   running: commit -m commit1 -d 2000-01-01 foo
--- a/tests/test-bookmarks-pushpull.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-bookmarks-pushpull.t	Tue Jun 20 09:45:02 2017 -0400
@@ -203,7 +203,7 @@
 
 (test that too many divergence of bookmark)
 
-  $ python $TESTDIR/seq.py 1 100 | while read i; do hg bookmarks -r 000000000000 "X@${i}"; done
+  $ $PYTHON $TESTDIR/seq.py 1 100 | while read i; do hg bookmarks -r 000000000000 "X@${i}"; done
   $ hg pull ../a
   pulling from ../a
   searching for changes
@@ -231,7 +231,7 @@
      @1                        2:0d2164f0ce0d
      @foo                      2:0d2164f0ce0d
 
-  $ python $TESTDIR/seq.py 1 100 | while read i; do hg bookmarks -d "X@${i}"; done
+  $ $PYTHON $TESTDIR/seq.py 1 100 | while read i; do hg bookmarks -d "X@${i}"; done
   $ hg bookmarks -d "@1"
 
   $ hg push -f ../a
--- a/tests/test-bundle2-remote-changegroup.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-bundle2-remote-changegroup.t	Tue Jun 20 09:45:02 2017 -0400
@@ -74,7 +74,7 @@
 
 Start a simple HTTP server to serve bundles
 
-  $ python "$TESTDIR/dumbhttp.py" -p $HGPORT --pid dumb.pid
+  $ $PYTHON "$TESTDIR/dumbhttp.py" -p $HGPORT --pid dumb.pid
   $ cat dumb.pid >> $DAEMON_PIDS
 
   $ cat >> $HGRCPATH << EOF
--- a/tests/test-censor.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-censor.t	Tue Jun 20 09:45:02 2017 -0400
@@ -304,7 +304,7 @@
 
 Can censor after revlog has expanded to no longer permit inline storage
 
-  $ for x in `python $TESTDIR/seq.py 0 50000`
+  $ for x in `$PYTHON $TESTDIR/seq.py 0 50000`
   > do
   >   echo "Password: hunter$x" >> target
   > done
--- a/tests/test-check-config.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-check-config.t	Tue Jun 20 09:45:02 2017 -0400
@@ -23,7 +23,7 @@
 
   $ cd "$TESTDIR"/..
 
-  $ python contrib/check-config.py < $TESTTMP/files
+  $ $PYTHON contrib/check-config.py < $TESTTMP/files
   undocumented: ui.doesnotexist (str)
   undocumented: ui.missingbool1 (bool) [True]
   undocumented: ui.missingbool2 (bool)
@@ -32,7 +32,7 @@
 New errors are not allowed. Warnings are strongly discouraged.
 
   $ hg files "set:(**.py or **.txt) - tests/**" | sed 's|\\|/|g' |
-  >   python contrib/check-config.py
+  >   $PYTHON contrib/check-config.py
               limit = ui.configwith(fraction, 'profiling', 'showmin', 0.05)
   
   conflict on profiling.showmin: ('with', '0.05') != ('with', '0.005')
--- a/tests/test-check-help.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-check-help.t	Tue Jun 20 09:45:02 2017 -0400
@@ -24,5 +24,5 @@
 (use "xargs -n1 -t" to see which help commands are executed)
 
   $ hg files 'glob:{hgdemandimport,hgext,mercurial}/**/*.py' | sed 's|\\|/|g' \
-  > | xargs python "$TESTTMP/scanhelptopics.py" \
+  > | xargs $PYTHON "$TESTTMP/scanhelptopics.py" \
   > | xargs -n1 hg help > /dev/null
--- a/tests/test-check-py3-compat.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-check-py3-compat.t	Tue Jun 20 09:45:02 2017 -0400
@@ -3,7 +3,7 @@
   $ . "$TESTDIR/helpers-testrepo.sh"
   $ cd "$TESTDIR"/..
 
-  $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs python contrib/check-py3-compat.py
+  $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs $PYTHON contrib/check-py3-compat.py
   contrib/python-zstandard/setup.py not using absolute_import
   contrib/python-zstandard/setup_zstd.py not using absolute_import
   contrib/python-zstandard/tests/common.py not using absolute_import
--- a/tests/test-chg.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-chg.t	Tue Jun 20 09:45:02 2017 -0400
@@ -89,7 +89,7 @@
   > [extensions]
   > pager =
   > [pager]
-  > pager = python $TESTTMP/fakepager.py
+  > pager = $PYTHON $TESTTMP/fakepager.py
   > EOF
   $ chg version > /dev/null
   $ touch foo
--- a/tests/test-clone-cgi.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-clone-cgi.t	Tue Jun 20 09:45:02 2017 -0400
@@ -27,7 +27,7 @@
   $ . "$TESTDIR/cgienv"
   $ QUERY_STRING="cmd=changegroup&roots=0000000000000000000000000000000000000000"; export QUERY_STRING
   $ python hgweb.cgi >page1 2>&1
-  $ python "$TESTDIR/md5sum.py" page1
+  $ $PYTHON "$TESTDIR/md5sum.py" page1
   1f424bb22ec05c3c6bc866b6e67efe43  page1
 
 make sure headers are sent even when there is no body
--- a/tests/test-clone.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-clone.t	Tue Jun 20 09:45:02 2017 -0400
@@ -524,7 +524,7 @@
   > hg.clone(myui, {}, repo, dest="ua")
   > EOF
 
-  $ python simpleclone.py
+  $ $PYTHON simpleclone.py
   updating to branch default
   3 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
@@ -538,7 +538,7 @@
   > hg.clone(myui, {}, repo, dest="ua", branch=["stable",])
   > EOF
 
-  $ python branchclone.py
+  $ $PYTHON branchclone.py
   adding changesets
   adding manifests
   adding file changes
--- a/tests/test-clonebundles.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-clonebundles.t	Tue Jun 20 09:45:02 2017 -0400
@@ -69,7 +69,7 @@
 
 Server returns 404
 
-  $ python $TESTDIR/dumbhttp.py -p $HGPORT1 --pid http.pid
+  $ $PYTHON $TESTDIR/dumbhttp.py -p $HGPORT1 --pid http.pid
   $ cat http.pid >> $DAEMON_PIDS
   $ hg clone http://localhost:$HGPORT running-404
   applying clone bundle from http://localhost:$HGPORT1/bundle.hg
--- a/tests/test-commit-interactive.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-commit-interactive.t	Tue Jun 20 09:45:02 2017 -0400
@@ -909,7 +909,7 @@
   >     sys.stdout.write(''.join(escape(c) for c in l))
   > EOF
 
-  $ hg commit -i --encoding cp932 2>&1 <<EOF | python $TESTTMP/escape.py | grep '^y - '
+  $ hg commit -i --encoding cp932 2>&1 <<EOF | $PYTHON $TESTTMP/escape.py | grep '^y - '
   > ?
   > q
   > EOF
--- a/tests/test-convert-bzr-ghosts.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-convert-bzr-ghosts.t	Tue Jun 20 09:45:02 2017 -0400
@@ -21,7 +21,7 @@
   $ bzr add -q somefile
   $ bzr commit -q -m 'Initial layout setup'
   $ echo morecontent >> somefile
-  $ python ../../ghostcreator.py 'Commit with ghost revision' ghostrev
+  $ $PYTHON ../../ghostcreator.py 'Commit with ghost revision' ghostrev
   $ cd ..
   $ hg convert source source-hg
   initializing destination source-hg repository
--- a/tests/test-convert-bzr-treeroot.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-convert-bzr-treeroot.t	Tue Jun 20 09:45:02 2017 -0400
@@ -20,7 +20,7 @@
   $ echo content > file
   $ bzr add -q file
   $ bzr commit -q -m 'Initial add'
-  $ python ../../treeset.py 'Changed root' new
+  $ $PYTHON ../../treeset.py 'Changed root' new
   $ cd ..
   $ hg convert source source-hg
   initializing destination source-hg repository
--- a/tests/test-convert-bzr.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-convert-bzr.t	Tue Jun 20 09:45:02 2017 -0400
@@ -129,10 +129,10 @@
   $ bzr branch -q source source-improve
   $ cd source
   $ echo more >> a
-  $ python ../helper.py 'Editing a' 100
+  $ $PYTHON ../helper.py 'Editing a' 100
   $ cd ../source-improve
   $ echo content3 >> b
-  $ python ../helper.py 'Editing b' 200
+  $ $PYTHON ../helper.py 'Editing b' 200
   $ cd ../source
   $ bzr merge -q ../source-improve
   $ bzr commit -q -m 'Merged improve branch'
--- a/tests/test-convert-clonebranches.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-convert-clonebranches.t	Tue Jun 20 09:45:02 2017 -0400
@@ -40,7 +40,7 @@
 convert
 
   $ hg convert -v --config convert.hg.clonebranches=1 source dest |
-  >     python filter.py
+  >     $PYTHON filter.py
   3 adda
   2 changea
   1 addb
@@ -73,7 +73,7 @@
 incremental conversion
 
   $ hg convert -v --config convert.hg.clonebranches=1 source dest |
-  >     python filter.py
+  >     $PYTHON filter.py
   2 c1
   pulling from branch0 into branch1
   4 changesets found
--- a/tests/test-convert-hg-source.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-convert-hg-source.t	Tue Jun 20 09:45:02 2017 -0400
@@ -130,7 +130,7 @@
   >          for i, l in enumerate(file(sys.argv[1]))]
   > file(sys.argv[1], 'wb').write(''.join(lines))
   > EOF
-  $ python rewrite.py new/.hg/shamap
+  $ $PYTHON rewrite.py new/.hg/shamap
   $ cd orig
   $ hg up -qC 1
   $ echo foo >> foo
--- a/tests/test-convert-svn-sink.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-convert-svn-sink.t	Tue Jun 20 09:45:02 2017 -0400
@@ -10,7 +10,7 @@
   >        if [ $2 -gt 0 ]; then
   >            limit="--limit=$2"
   >        fi
-  >        svn log --xml -v $limit | python "$TESTDIR/svnxml.py"
+  >        svn log --xml -v $limit | $PYTHON "$TESTDIR/svnxml.py"
   >     )
   > }
 
--- a/tests/test-debugcommands.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-debugcommands.t	Tue Jun 20 09:45:02 2017 -0400
@@ -142,7 +142,7 @@
   >     dst('hi ...\\nfrom h hidden in g', 1, depth=2)
   > f()
   > EOF
-  $ python debugstacktrace.py
+  $ $PYTHON debugstacktrace.py
   stacktrace at:
    debugstacktrace.py:10 in * (glob)
    debugstacktrace.py:3  in f
--- a/tests/test-diff-binary-file.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-diff-binary-file.t	Tue Jun 20 09:45:02 2017 -0400
@@ -83,7 +83,7 @@
   > path = sys.argv[1]
   > open(path, 'wb').write('\x00\x01\x02\x03')
   > EOF
-  $ python writebin.py binfile.bin
+  $ $PYTHON writebin.py binfile.bin
   $ hg add binfile.bin
   $ hg ci -m 'add binfile.bin'
 
--- a/tests/test-eol.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-eol.t	Tue Jun 20 09:45:02 2017 -0400
@@ -69,7 +69,7 @@
   >     echo '% a.txt'
   >     cat a.txt
   >     hg diff
-  >     python ../switch-eol.py $1 a.txt
+  >     $PYTHON ../switch-eol.py $1 a.txt
   >     echo '% hg diff only reports a single changed line:'
   >     hg diff
   >     echo "% reverting back to $1 format"
--- a/tests/test-fileset-generated.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-fileset-generated.t	Tue Jun 20 09:45:02 2017 -0400
@@ -2,15 +2,15 @@
 
 Set up history and working copy
 
-  $ python $TESTDIR/generate-working-copy-states.py state 2 1
+  $ $PYTHON $TESTDIR/generate-working-copy-states.py state 2 1
   $ hg addremove -q --similarity 0
   $ hg commit -m first
 
-  $ python $TESTDIR/generate-working-copy-states.py state 2 2
+  $ $PYTHON $TESTDIR/generate-working-copy-states.py state 2 2
   $ hg addremove -q --similarity 0
   $ hg commit -m second
 
-  $ python $TESTDIR/generate-working-copy-states.py state 2 wc
+  $ $PYTHON $TESTDIR/generate-working-copy-states.py state 2 wc
   $ hg addremove -q --similarity 0
   $ hg forget *_*_*-untracked
   $ rm *_*_missing-*
--- a/tests/test-gendoc.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-gendoc.t	Tue Jun 20 09:45:02 2017 -0400
@@ -8,7 +8,7 @@
   $ { echo C; ls "$TESTDIR/../i18n"/*.po | sort; } | while read PO; do
   >     LOCALE=`basename "$PO" .po`
   >     echo "% extracting documentation from $LOCALE"
-  >     LANGUAGE=$LOCALE python "$TESTDIR/../doc/gendoc.py" >> gendoc-$LOCALE.txt 2> /dev/null || exit
+  >     LANGUAGE=$LOCALE $PYTHON "$TESTDIR/../doc/gendoc.py" >> gendoc-$LOCALE.txt 2> /dev/null || exit
   > 
   >     if [ $LOCALE != C ]; then
   >         if [ ! -f $TESTDIR/test-gendoc-$LOCALE.t ]; then
--- a/tests/test-hardlinks.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-hardlinks.t	Tue Jun 20 09:45:02 2017 -0400
@@ -10,7 +10,7 @@
 
   $ nlinksdir()
   > {
-  >     find "$@" -type f | python $TESTTMP/nlinks.py
+  >     find "$@" -type f | $PYTHON $TESTTMP/nlinks.py
   > }
 
 Some implementations of cp can't create hardlinks (replaces 'cp -al' on Linux):
@@ -23,7 +23,7 @@
 
   $ linkcp()
   > {
-  >     python $TESTTMP/linkcp.py $1 $2
+  >     $PYTHON $TESTTMP/linkcp.py $1 $2
   > }
 
 Prepare repo r1:
--- a/tests/test-help.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-help.t	Tue Jun 20 09:45:02 2017 -0400
@@ -1867,7 +1867,7 @@
 Test usage of section marks in help documents
 
   $ cd "$TESTDIR"/../doc
-  $ python check-seclevel.py
+  $ $PYTHON check-seclevel.py
   $ cd $TESTTMP
 
 #if serve
--- a/tests/test-hgignore.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-hgignore.t	Tue Jun 20 09:45:02 2017 -0400
@@ -19,7 +19,7 @@
   > f.close()
   > EOF
 
-  $ python makeignore.py
+  $ $PYTHON makeignore.py
 
 Should display baz only:
 
--- a/tests/test-hgweb-no-path-info.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-hgweb-no-path-info.t	Tue Jun 20 09:45:02 2017 -0400
@@ -70,7 +70,7 @@
   > env['QUERY_STRING'] = 'style=raw'
   > process(hgwebdir({'repo': '.'}))
   > EOF
-  $ python request.py
+  $ $PYTHON request.py
   ---- STATUS
   200 Script output follows
   ---- HEADERS
--- a/tests/test-hgweb-no-request-uri.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-hgweb-no-request-uri.t	Tue Jun 20 09:45:02 2017 -0400
@@ -81,7 +81,7 @@
   > env['QUERY_STRING'] = 'style=raw'
   > process(hgwebdir({'repo': '.'}))
   > EOF
-  $ python request.py
+  $ $PYTHON request.py
   ---- STATUS
   200 Script output follows
   ---- HEADERS
--- a/tests/test-hgweb-non-interactive.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-hgweb-non-interactive.t	Tue Jun 20 09:45:02 2017 -0400
@@ -76,7 +76,7 @@
   > with i._obtainrepo() as repo:
   >     print sorted([x for x in repo.ui.environ if x.startswith('wsgi')])
   > EOF
-  $ python request.py
+  $ $PYTHON request.py
   ---- STATUS
   200 Script output follows
   ---- HEADERS
--- a/tests/test-i18n.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-i18n.t	Tue Jun 20 09:45:02 2017 -0400
@@ -45,6 +45,6 @@
 tool itself by doctest
 
   $ cd "$TESTDIR"/../i18n
-  $ python check-translation.py *.po
-  $ python check-translation.py --doctest
+  $ $PYTHON check-translation.py *.po
+  $ $PYTHON check-translation.py --doctest
   $ cd $TESTTMP
--- a/tests/test-impexp-branch.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-impexp-branch.t	Tue Jun 20 09:45:02 2017 -0400
@@ -30,12 +30,12 @@
   $ hg export 1 > ../r1.patch
   $ cd ..
 
-  $ if python findbranch.py < r0.patch; then
+  $ if $PYTHON findbranch.py < r0.patch; then
   >     echo "Export of default branch revision has Branch header" 1>&2
   >     exit 1
   > fi
 
-  $ if python findbranch.py < r1.patch; then
+  $ if $PYTHON findbranch.py < r1.patch; then
   >     :  # Do nothing
   > else
   >     echo "Export of branch revision is missing Branch header" 1>&2
--- a/tests/test-import-context.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-import-context.t	Tue Jun 20 09:45:02 2017 -0400
@@ -26,10 +26,10 @@
 
   $ hg init repo
   $ cd repo
-  $ python ../writepatterns.py a 0 5A 1B 5C 1D
-  $ python ../writepatterns.py b 1 1A 1B
-  $ python ../writepatterns.py c 1 5A
-  $ python ../writepatterns.py d 1 5A 1B
+  $ $PYTHON ../writepatterns.py a 0 5A 1B 5C 1D
+  $ $PYTHON ../writepatterns.py b 1 1A 1B
+  $ $PYTHON ../writepatterns.py c 1 5A
+  $ $PYTHON ../writepatterns.py d 1 5A 1B
   $ hg add
   adding a
   adding b
@@ -114,13 +114,13 @@
 
 What's in a
 
-  $ python ../cat.py a
+  $ $PYTHON ../cat.py a
   'A\nA\nA\nA\nA\nE\nC\nC\nC\nC\nC\nF\nF\n'
-  $ python ../cat.py newnoeol
+  $ $PYTHON ../cat.py newnoeol
   'a\nb'
-  $ python ../cat.py c
+  $ $PYTHON ../cat.py c
   'A\nA\nA\nA\nA\nB\nB\n'
-  $ python ../cat.py d
+  $ $PYTHON ../cat.py d
   'A\nA\nA\nA\n'
 
   $ cd ..
--- a/tests/test-import-eol.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-import-eol.t	Tue Jun 20 09:45:02 2017 -0400
@@ -29,7 +29,7 @@
   $ hg ci -Am adda
   adding .hgignore
   adding a
-  $ python ../makepatch.py
+  $ $PYTHON ../makepatch.py
 
 
 invalid eol
--- a/tests/test-import.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-import.t	Tue Jun 20 09:45:02 2017 -0400
@@ -64,7 +64,7 @@
   added 1 changesets with 2 changes to 2 files
   updating to branch default
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ HGEDITOR=cat hg --config ui.patch='python ../dummypatch.py' --cwd b import --edit ../exported-tip.patch
+  $ HGEDITOR=cat hg --config ui.patch='$PYTHON ../dummypatch.py' --cwd b import --edit ../exported-tip.patch
   applying ../exported-tip.patch
   second change
   
@@ -294,7 +294,7 @@
   added 1 changesets with 2 changes to 2 files
   updating to branch default
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ python mkmsg.py diffed-tip.patch msg.patch
+  $ $PYTHON mkmsg.py diffed-tip.patch msg.patch
   $ hg --cwd b import ../msg.patch
   applying ../msg.patch
   $ hg --cwd b tip | grep email
@@ -356,7 +356,7 @@
   added 1 changesets with 2 changes to 2 files
   updating to branch default
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ python mkmsg.py exported-tip.patch msg.patch
+  $ $PYTHON mkmsg.py exported-tip.patch msg.patch
   $ cat msg.patch | hg --cwd b import -
   applying patch from stdin
   $ hg --cwd b tip | grep second
@@ -387,7 +387,7 @@
   added 1 changesets with 2 changes to 2 files
   updating to branch default
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ python mkmsg2.py diffed-tip.patch msg.patch
+  $ $PYTHON mkmsg2.py diffed-tip.patch msg.patch
   $ cat msg.patch | hg --cwd b import -
   applying patch from stdin
   $ hg --cwd b tip --template '{desc}\n'
--- a/tests/test-imports-checker.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-imports-checker.t	Tue Jun 20 09:45:02 2017 -0400
@@ -124,7 +124,7 @@
   > from mercurial.node import hex
   > EOF
 
-  $ python "$import_checker" testpackage*/*.py testpackage/subpackage/*.py
+  $ $PYTHON "$import_checker" testpackage*/*.py testpackage/subpackage/*.py
   testpackage/importalias.py:2: ui module must be "as" aliased to uimod
   testpackage/importfromalias.py:2: ui from testpackage must be "as" aliased to uimod
   testpackage/importfromrelative.py:2: import should be relative: testpackage.unsorted
--- a/tests/test-inherit-mode.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-inherit-mode.t	Tue Jun 20 09:45:02 2017 -0400
@@ -45,7 +45,7 @@
 store can be written by the group, other files cannot
 store is setgid
 
-  $ python ../printmodes.py .
+  $ $PYTHON ../printmodes.py .
   00700 ./.hg/
   00600 ./.hg/00changelog.i
   00600 ./.hg/requires
@@ -61,7 +61,7 @@
 (in particular, store/**, dirstate, branch cache file, undo files)
 new directories are setgid
 
-  $ python ../printmodes.py .
+  $ $PYTHON ../printmodes.py .
   00700 ./.hg/
   00600 ./.hg/00changelog.i
   00770 ./.hg/cache/
@@ -98,7 +98,7 @@
 before push
 group can write everything
 
-  $ python ../printmodes.py ../push
+  $ $PYTHON ../printmodes.py ../push
   00770 ../push/.hg/
   00660 ../push/.hg/00changelog.i
   00660 ../push/.hg/requires
@@ -110,7 +110,7 @@
 after push
 group can still write everything
 
-  $ python ../printmodes.py ../push
+  $ $PYTHON ../printmodes.py ../push
   00770 ../push/.hg/
   00660 ../push/.hg/00changelog.i
   00770 ../push/.hg/cache/
@@ -146,8 +146,8 @@
   $ mkdir dir
   $ touch dir/file
   $ hg ci -qAm 'add dir/file'
-  $ storemode=`python ../mode.py .hg/store`
-  $ dirmode=`python ../mode.py .hg/store/data/dir`
+  $ storemode=`$PYTHON ../mode.py .hg/store`
+  $ dirmode=`$PYTHON ../mode.py .hg/store/data/dir`
   $ if [ "$storemode" != "$dirmode" ]; then
   >  echo "$storemode != $dirmode"
   > fi
--- a/tests/test-install.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-install.t	Tue Jun 20 09:45:02 2017 -0400
@@ -159,7 +159,7 @@
   >     print('  %s' % f)
   > EOF
 
-  $ python wixxml.py help
+  $ $PYTHON wixxml.py help
   Not installed:
     help/common.txt
     help/hg-ssh.8.txt
@@ -168,7 +168,7 @@
     help/hgrc.5.txt
   Not tracked:
 
-  $ python wixxml.py templates
+  $ $PYTHON wixxml.py templates
   Not installed:
   Not tracked:
 
--- a/tests/test-issue4074.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-issue4074.t	Tue Jun 20 09:45:02 2017 -0400
@@ -16,12 +16,12 @@
 
 Check in a big file:
 
-  $ python ../s.py > a
+  $ $PYTHON ../s.py > a
   $ hg ci -qAm0
 
 Modify it:
 
-  $ python ../s.py > a
+  $ $PYTHON ../s.py > a
 
 Time a check-in, should never take more than 10 seconds user time:
 
--- a/tests/test-mactext.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-mactext.t	Tue Jun 20 09:45:02 2017 -0400
@@ -24,7 +24,7 @@
   $ hg add f
   $ hg ci -m 1
 
-  $ python unix2mac.py f
+  $ $PYTHON unix2mac.py f
   $ hg ci -m 2
   attempt to commit or push text file(s) using CR line endings
   in dea860dc51ec: f
@@ -32,7 +32,7 @@
   rollback completed
   abort: pretxncommit.cr hook failed
   [255]
-  $ hg cat f | python print.py
+  $ hg cat f | $PYTHON print.py
   hello<LF>
-  $ cat f | python print.py
+  $ cat f | $PYTHON print.py
   hello<CR>
--- a/tests/test-merge-force.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-merge-force.t	Tue Jun 20 09:45:02 2017 -0400
@@ -10,26 +10,26 @@
 
 Create base changeset
 
-  $ python $TESTDIR/generate-working-copy-states.py state 3 1
+  $ $PYTHON $TESTDIR/generate-working-copy-states.py state 3 1
   $ hg addremove -q --similarity 0
   $ hg commit -qm 'base'
 
 Create remote changeset
 
-  $ python $TESTDIR/generate-working-copy-states.py state 3 2
+  $ $PYTHON $TESTDIR/generate-working-copy-states.py state 3 2
   $ hg addremove -q --similarity 0
   $ hg commit -qm 'remote'
 
 Create local changeset
 
   $ hg update -q 0
-  $ python $TESTDIR/generate-working-copy-states.py state 3 3
+  $ $PYTHON $TESTDIR/generate-working-copy-states.py state 3 3
   $ hg addremove -q --similarity 0
   $ hg commit -qm 'local'
 
 Set up working directory
 
-  $ python $TESTDIR/generate-working-copy-states.py state 3 wc
+  $ $PYTHON $TESTDIR/generate-working-copy-states.py state 3 wc
   $ hg addremove -q --similarity 0
   $ hg forget *_*_*_*-untracked
   $ rm *_*_*_missing-*
@@ -286,7 +286,7 @@
 the remote side did not touch the file
 
   $ checkstatus() {
-  >   for f in `python $TESTDIR/generate-working-copy-states.py filelist 3`
+  >   for f in `$PYTHON $TESTDIR/generate-working-copy-states.py filelist 3`
   >   do
   >     echo
   >     hg status -A $f
@@ -667,7 +667,7 @@
   missing_missing_missing_missing-untracked: * (glob)
   <missing>
 
-  $ for f in `python $TESTDIR/generate-working-copy-states.py filelist 3`
+  $ for f in `$PYTHON $TESTDIR/generate-working-copy-states.py filelist 3`
   > do
   >   if test -f ${f}.orig
   >   then
@@ -784,7 +784,7 @@
 
   $ hg -q update --clean 2
   $ hg --config extensions.purge= purge
-  $ python $TESTDIR/generate-working-copy-states.py state 3 wc
+  $ $PYTHON $TESTDIR/generate-working-copy-states.py state 3 wc
   $ hg addremove -q --similarity 0
   $ hg forget *_*_*_*-untracked
   $ rm *_*_*_missing-*
--- a/tests/test-merge-symlinks.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-merge-symlinks.t	Tue Jun 20 09:45:02 2017 -0400
@@ -36,7 +36,7 @@
 Merge them and display *_ISLINK vars
 merge heads
 
-  $ hg merge --tool="python ../echo.py"
+  $ hg merge --tool="$PYTHON ../echo.py"
   merging l
   HG_FILE l
   HG_MY_ISLINK 1
@@ -52,7 +52,7 @@
   $ hg up -C 2
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ hg copy l l2
-  $ HGMERGE="python ../echo.py" hg up 3
+  $ HGMERGE="$PYTHON ../echo.py" hg up 3
   merging l2
   HG_FILE l2
   HG_MY_ISLINK 1
--- a/tests/test-mq-eol.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-mq-eol.t	Tue Jun 20 09:45:02 2017 -0400
@@ -48,7 +48,7 @@
   $ hg ci -Am adda
   adding .hgignore
   adding a
-  $ python ../makepatch.py
+  $ $PYTHON ../makepatch.py
   $ hg qimport eol.diff
   adding eol.diff to series file
 
@@ -85,7 +85,7 @@
   applying eol.diff
   now at: eol.diff
   $ hg qrefresh
-  $ python ../cateol.py .hg/patches/eol.diff
+  $ $PYTHON ../cateol.py .hg/patches/eol.diff
   # HG changeset patch<LF>
   # Parent  0d0bf99a8b7a3842c6f8ef09e34f69156c4bd9d0<LF>
   test message<LF>
@@ -106,7 +106,7 @@
   +d<CR><LF>
   +z<LF>
   \ No newline at end of file<LF>
-  $ python ../cateol.py a
+  $ $PYTHON ../cateol.py a
   a<CR><LF>
   y<CR><LF>
   c<CR><LF>
@@ -121,7 +121,7 @@
   $ hg --config patch.eol='CRLF' qpush
   applying eol.diff
   now at: eol.diff
-  $ python ../cateol.py a
+  $ $PYTHON ../cateol.py a
   a<CR><LF>
   y<CR><LF>
   c<CR><LF>
@@ -136,7 +136,7 @@
   $ hg qpush
   applying eol.diff
   now at: eol.diff
-  $ python ../cateol.py a
+  $ $PYTHON ../cateol.py a
   a<CR><LF>
   y<CR><LF>
   c<CR><LF>
--- a/tests/test-mq-missingfiles.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-mq-missingfiles.t	Tue Jun 20 09:45:02 2017 -0400
@@ -23,11 +23,11 @@
 
   $ hg init normal
   $ cd normal
-  $ python ../writelines.py b 10 'a\n'
+  $ $PYTHON ../writelines.py b 10 'a\n'
   $ hg ci -Am addb
   adding b
   $ echo a > a
-  $ python ../writelines.py b 2 'b\n' 10 'a\n' 2 'c\n'
+  $ $PYTHON ../writelines.py b 2 'b\n' 10 'a\n' 2 'c\n'
   $ echo c > c
   $ hg add a c
   $ hg qnew -f changeb
@@ -82,7 +82,7 @@
   $ hg up -qC 0
   $ echo a > a
   $ hg mv b bb
-  $ python ../writelines.py bb 2 'b\n' 10 'a\n' 2 'c\n'
+  $ $PYTHON ../writelines.py bb 2 'b\n' 10 'a\n' 2 'c\n'
   $ echo c > c
   $ hg add a c
   $ hg qnew changebb
@@ -129,11 +129,11 @@
 
   $ hg init git
   $ cd git
-  $ python ../writelines.py b 1 '\x00'
+  $ $PYTHON ../writelines.py b 1 '\x00'
   $ hg ci -Am addb
   adding b
   $ echo a > a
-  $ python ../writelines.py b 1 '\x01' 1 '\x00'
+  $ $PYTHON ../writelines.py b 1 '\x01' 1 '\x00'
   $ echo c > c
   $ hg add a c
   $ hg qnew -f changeb
--- a/tests/test-mq-qimport.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-mq-qimport.t	Tue Jun 20 09:45:02 2017 -0400
@@ -151,10 +151,10 @@
 
 build diff with CRLF
 
-  $ python ../writelines.py b 5 'a\n' 5 'a\r\n'
+  $ $PYTHON ../writelines.py b 5 'a\n' 5 'a\r\n'
   $ hg ci -Am addb
   adding b
-  $ python ../writelines.py b 2 'a\n' 10 'b\n' 2 'a\r\n'
+  $ $PYTHON ../writelines.py b 2 'a\n' 10 'b\n' 2 'a\r\n'
   $ hg diff > b.diff
   $ hg up -C
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
--- a/tests/test-mq.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-mq.t	Tue Jun 20 09:45:02 2017 -0400
@@ -1137,9 +1137,9 @@
   > path = sys.argv[1]
   > open(path, 'wb').write('BIN\x00ARY')
   > EOF
-  $ python writebin.py bucephalus
+  $ $PYTHON writebin.py bucephalus
 
-  $ python "$TESTDIR/md5sum.py" bucephalus
+  $ $PYTHON "$TESTDIR/md5sum.py" bucephalus
   8ba2a2f3e77b55d03051ff9c24ad65e7  bucephalus
   $ hg add bucephalus
   $ hg qnew -f --git addbucephalus
@@ -1158,7 +1158,7 @@
   applying addbucephalus
   now at: addbucephalus
   $ test -f bucephalus
-  $ python "$TESTDIR/md5sum.py" bucephalus
+  $ $PYTHON "$TESTDIR/md5sum.py" bucephalus
   8ba2a2f3e77b55d03051ff9c24ad65e7  bucephalus
 
 
--- a/tests/test-pager-legacy.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-pager-legacy.t	Tue Jun 20 09:45:02 2017 -0400
@@ -14,7 +14,7 @@
   > [extensions]
   > pager=
   > [pager]
-  > pager = python $TESTTMP/fakepager.py
+  > pager = $PYTHON $TESTTMP/fakepager.py
   > EOF
 
   $ hg init repo
@@ -22,7 +22,7 @@
   $ echo a >> a
   $ hg add a
   $ hg ci -m 'add a'
-  $ for x in `python $TESTDIR/seq.py 1 10`; do
+  $ for x in `$PYTHON $TESTDIR/seq.py 1 10`; do
   >   echo a $x >> a
   >   hg ci -m "modify a $x"
   > done
--- a/tests/test-pager.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-pager.t	Tue Jun 20 09:45:02 2017 -0400
@@ -16,7 +16,7 @@
   > formatted = yes
   > color = no
   > [pager]
-  > pager = python $TESTTMP/fakepager.py
+  > pager = $PYTHON $TESTTMP/fakepager.py
   > EOF
 
   $ hg init repo
@@ -24,7 +24,7 @@
   $ echo a >> a
   $ hg add a
   $ hg ci -m 'add a'
-  $ for x in `python $TESTDIR/seq.py 1 10`; do
+  $ for x in `$PYTHON $TESTDIR/seq.py 1 10`; do
   >   echo a $x >> a
   >   hg ci -m "modify a $x"
   > done
--- a/tests/test-parseindex.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-parseindex.t	Tue Jun 20 09:45:02 2017 -0400
@@ -53,7 +53,7 @@
   > for r in cl:
   >     print short(cl.node(r))
   > EOF
-  $ python test.py
+  $ $PYTHON test.py
   2 revisions:
   7c31755bf9b5
   26333235a41c
@@ -167,13 +167,13 @@
   >         print inst
   > EOF
 
-  $ python test.py limit/.hg/store
+  $ $PYTHON test.py limit/.hg/store
   reachableroots: parent out of range
   compute_phases_map_sets: parent out of range
   index_headrevs: parent out of range
   find_gca_candidates: parent out of range
   find_deepest: parent out of range
-  $ python test.py segv/.hg/store
+  $ $PYTHON test.py segv/.hg/store
   reachableroots: parent out of range
   compute_phases_map_sets: parent out of range
   index_headrevs: parent out of range
--- a/tests/test-patch-offset.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-patch-offset.t	Tue Jun 20 09:45:02 2017 -0400
@@ -23,7 +23,7 @@
 within this file.  If the offset isn't tracked then the hunks can be
 applied to the wrong lines of this file.
 
-  $ python ../writepatterns.py a 34X 10A 1B 10A 1C 10A 1B 10A 1D 10A 1B 10A 1E 10A 1B 10A
+  $ $PYTHON ../writepatterns.py a 34X 10A 1B 10A 1C 10A 1B 10A 1D 10A 1B 10A 1E 10A 1B 10A
   $ hg commit -Am adda
   adding a
 
@@ -76,7 +76,7 @@
 
 compare imported changes against reference file
 
-  $ python ../writepatterns.py aref 34X 10A 1B 1a 9A 1C 10A 1B 10A 1D 10A 1B 1a 9A 1E 10A 1B 1a 9A
+  $ $PYTHON ../writepatterns.py aref 34X 10A 1B 1a 9A 1C 10A 1B 10A 1D 10A 1B 1a 9A 1E 10A 1B 1a 9A
   $ diff aref a
 
   $ cd ..
--- a/tests/test-patch.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-patch.t	Tue Jun 20 09:45:02 2017 -0400
@@ -6,7 +6,7 @@
   > EOF
 
   $ echo "[ui]" >> $HGRCPATH
-  $ echo "patch=python ../patchtool.py" >> $HGRCPATH
+  $ echo "patch=$PYTHON ../patchtool.py" >> $HGRCPATH
 
   $ hg init a
   $ cd a
--- a/tests/test-patchbomb-tls.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-patchbomb-tls.t	Tue Jun 20 09:45:02 2017 -0400
@@ -5,7 +5,7 @@
   $ CERTSDIR="$TESTDIR/sslcerts"
   $ cat "$CERTSDIR/priv.pem" "$CERTSDIR/pub.pem" >> server.pem
 
-  $ python "$TESTDIR/dummysmtpd.py" -p $HGPORT --pid-file a.pid -d \
+  $ $PYTHON "$TESTDIR/dummysmtpd.py" -p $HGPORT --pid-file a.pid -d \
   > --tls smtps --certificate `pwd`/server.pem
   listening at localhost:$HGPORT (?)
   $ cat a.pid >> $DAEMON_PIDS
--- a/tests/test-patchbomb.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-patchbomb.t	Tue Jun 20 09:45:02 2017 -0400
@@ -22,7 +22,7 @@
   >     skipblank = False
   >     print l,
   > EOF
-  $ FILTERBOUNDARY="python `pwd`/prune-blank-after-boundary.py"
+  $ FILTERBOUNDARY="$PYTHON `pwd`/prune-blank-after-boundary.py"
   $ echo "[format]" >> $HGRCPATH
   $ echo "usegeneraldelta=yes" >> $HGRCPATH
   $ echo "[extensions]" >> $HGRCPATH
--- a/tests/test-push-warn.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-push-warn.t	Tue Jun 20 09:45:02 2017 -0400
@@ -418,7 +418,7 @@
   adding c
   created new head
 
-  $ for i in `python $TESTDIR/seq.py 3`; do hg -R h up -q 0; echo $i > h/b; hg -R h ci -qAm$i; done
+  $ for i in `$PYTHON $TESTDIR/seq.py 3`; do hg -R h up -q 0; echo $i > h/b; hg -R h ci -qAm$i; done
 
   $ hg -R i push h
   pushing to h
--- a/tests/test-relink.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-relink.t	Tue Jun 20 09:45:02 2017 -0400
@@ -93,8 +93,8 @@
 
 check hardlinks
 
-  $ python arelinked.py repo/.hg/store/data/a.i clone/.hg/store/data/a.i
+  $ $PYTHON arelinked.py repo/.hg/store/data/a.i clone/.hg/store/data/a.i
   repo/.hg/store/data/a.i == clone/.hg/store/data/a.i
-  $ python arelinked.py repo/.hg/store/data/b.i clone/.hg/store/data/b.i
+  $ $PYTHON arelinked.py repo/.hg/store/data/b.i clone/.hg/store/data/b.i
   repo/.hg/store/data/b.i != clone/.hg/store/data/b.i
 
--- a/tests/test-repair-strip.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-repair-strip.t	Tue Jun 20 09:45:02 2017 -0400
@@ -21,7 +21,7 @@
   >   hg verify
   >   echo % journal contents
   >   if [ -f .hg/store/journal ]; then
-  >       cat .hg/store/journal | python $TESTTMP/dumpjournal.py
+  >       cat .hg/store/journal | $PYTHON $TESTTMP/dumpjournal.py
   >   else
   >       echo "(no journal)"
   >   fi
--- a/tests/test-revert.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-revert.t	Tue Jun 20 09:45:02 2017 -0400
@@ -495,7 +495,7 @@
 
 check list of planned files
 
-  $ python $TESTDIR/generate-working-copy-states.py filelist 2
+  $ $PYTHON $TESTDIR/generate-working-copy-states.py filelist 2
   content1_content1_content1-tracked
   content1_content1_content1-untracked
   content1_content1_content3-tracked
@@ -550,7 +550,7 @@
 
 Generate base changeset
 
-  $ python $TESTDIR/generate-working-copy-states.py state 2 1
+  $ $PYTHON $TESTDIR/generate-working-copy-states.py state 2 1
   $ hg addremove --similarity 0
   adding content1_content1_content1-tracked
   adding content1_content1_content1-untracked
@@ -597,7 +597,7 @@
 
 (create a simple text version of the content)
 
-  $ python ../dircontent.py > ../content-base.txt
+  $ $PYTHON ../dircontent.py > ../content-base.txt
   $ cat ../content-base.txt
   content1 content1_content1_content1-tracked
   content1 content1_content1_content1-untracked
@@ -622,7 +622,7 @@
 
 Create parent changeset
 
-  $ python $TESTDIR/generate-working-copy-states.py state 2 2
+  $ $PYTHON $TESTDIR/generate-working-copy-states.py state 2 2
   $ hg addremove --similarity 0
   removing content1_missing_content1-tracked
   removing content1_missing_content1-untracked
@@ -661,7 +661,7 @@
 
 (create a simple text version of the content)
 
-  $ python ../dircontent.py > ../content-parent.txt
+  $ $PYTHON ../dircontent.py > ../content-parent.txt
   $ cat ../content-parent.txt
   content1 content1_content1_content1-tracked
   content1 content1_content1_content1-untracked
@@ -686,7 +686,7 @@
 
 Setup working directory
 
-  $ python $TESTDIR/generate-working-copy-states.py state 2 wc
+  $ $PYTHON $TESTDIR/generate-working-copy-states.py state 2 wc
   $ hg addremove --similarity 0
   adding content1_missing_content1-tracked
   adding content1_missing_content1-untracked
@@ -754,7 +754,7 @@
 
 (create a simple text version of the content)
 
-  $ python ../dircontent.py > ../content-wc.txt
+  $ $PYTHON ../dircontent.py > ../content-wc.txt
   $ cat ../content-wc.txt
   content1 content1_content1_content1-tracked
   content1 content1_content1_content1-untracked
@@ -818,7 +818,7 @@
 The diff is filtered to include change only. The only difference should be
 additional `.orig` backup file when applicable.
 
-  $ python ../dircontent.py > ../content-parent-all.txt
+  $ $PYTHON ../dircontent.py > ../content-parent-all.txt
   $ cd ..
   $ diff -U 0 -- content-parent.txt content-parent-all.txt | grep _
   +content3 content1_content1_content3-tracked.orig
@@ -875,7 +875,7 @@
 The diff is filtered to include change only. The only difference should be
 additional `.orig` backup file when applicable.
 
-  $ python ../dircontent.py > ../content-base-all.txt
+  $ $PYTHON ../dircontent.py > ../content-base-all.txt
   $ cd ..
   $ diff -U 0 -- content-base.txt content-base-all.txt | grep _
   +content3 content1_content1_content3-tracked.orig
@@ -902,7 +902,7 @@
 revert all files individually and check the output
 (output is expected to be different than in the --all case)
 
-  $ for file in `python $TESTDIR/generate-working-copy-states.py filelist 2`; do
+  $ for file in `$PYTHON $TESTDIR/generate-working-copy-states.py filelist 2`; do
   >   echo '### revert for:' $file;
   >   hg revert $file;
   >   echo
@@ -979,7 +979,7 @@
 check resulting directory against the --all run
 (There should be no difference)
 
-  $ python ../dircontent.py > ../content-parent-explicit.txt
+  $ $PYTHON ../dircontent.py > ../content-parent-explicit.txt
   $ cd ..
   $ diff -U 0 -- content-parent-all.txt content-parent-explicit.txt | grep _
   [1]
@@ -995,7 +995,7 @@
 revert all files individually and check the output
 (output is expected to be different than in the --all case)
 
-  $ for file in `python $TESTDIR/generate-working-copy-states.py filelist 2`; do
+  $ for file in `$PYTHON $TESTDIR/generate-working-copy-states.py filelist 2`; do
   >   echo '### revert for:' $file;
   >   hg revert $file --rev 'desc(base)';
   >   echo
@@ -1072,7 +1072,7 @@
 check resulting directory against the --all run
 (There should be no difference)
 
-  $ python ../dircontent.py > ../content-base-explicit.txt
+  $ $PYTHON ../dircontent.py > ../content-base-explicit.txt
   $ cd ..
   $ diff -U 0 -- content-base-all.txt content-base-explicit.txt | grep _
   [1]
--- a/tests/test-setdiscovery.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-setdiscovery.t	Tue Jun 20 09:45:02 2017 -0400
@@ -363,9 +363,9 @@
 #if false
 generate new bundles:
   $ hg init r1
-  $ for i in `python $TESTDIR/seq.py 101`; do hg -R r1 up -qr null && hg -R r1 branch -q b$i && hg -R r1 ci -qmb$i; done
+  $ for i in `$PYTHON $TESTDIR/seq.py 101`; do hg -R r1 up -qr null && hg -R r1 branch -q b$i && hg -R r1 ci -qmb$i; done
   $ hg clone -q r1 r2
-  $ for i in `python $TESTDIR/seq.py 10`; do hg -R r1 up -qr null && hg -R r1 branch -q c$i && hg -R r1 ci -qmc$i; done
+  $ for i in `$PYTHON $TESTDIR/seq.py 10`; do hg -R r1 up -qr null && hg -R r1 branch -q c$i && hg -R r1 ci -qmc$i; done
   $ hg -R r2 branch -q r2change && hg -R r2 ci -qmr2change
   $ hg -R r1 bundle -qa $TESTDIR/bundles/issue4438-r1.hg
   $ hg -R r2 bundle -qa $TESTDIR/bundles/issue4438-r2.hg
--- a/tests/test-simple-update.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-simple-update.t	Tue Jun 20 09:45:02 2017 -0400
@@ -77,7 +77,7 @@
   > [worker]
   > numcpus = 4
   > EOF
-  $ for i in `python $TESTDIR/seq.py 1 100`; do
+  $ for i in `$PYTHON $TESTDIR/seq.py 1 100`; do
   >   echo $i > $i
   > done
   $ hg ci -qAm 'add 100 files'
--- a/tests/test-static-http.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-static-http.t	Tue Jun 20 09:45:02 2017 -0400
@@ -9,7 +9,7 @@
 This server doesn't do range requests so it's basically only good for
 one pull
 
-  $ python "$TESTDIR/dumbhttp.py" -p $HGPORT --pid dumb.pid
+  $ $PYTHON "$TESTDIR/dumbhttp.py" -p $HGPORT --pid dumb.pid
   $ cat dumb.pid >> $DAEMON_PIDS
   $ hg init remote
   $ cd remote
--- a/tests/test-status-rev.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-status-rev.t	Tue Jun 20 09:45:02 2017 -0400
@@ -5,7 +5,7 @@
 
 First commit
 
-  $ python $TESTDIR/generate-working-copy-states.py state 2 1
+  $ $PYTHON $TESTDIR/generate-working-copy-states.py state 2 1
   $ hg addremove --similarity 0
   adding content1_content1_content1-tracked
   adding content1_content1_content1-untracked
@@ -31,7 +31,7 @@
 
 Second commit
 
-  $ python $TESTDIR/generate-working-copy-states.py state 2 2
+  $ $PYTHON $TESTDIR/generate-working-copy-states.py state 2 2
   $ hg addremove --similarity 0
   removing content1_missing_content1-tracked
   removing content1_missing_content1-untracked
@@ -49,7 +49,7 @@
 
 Working copy
 
-  $ python $TESTDIR/generate-working-copy-states.py state 2 wc
+  $ $PYTHON $TESTDIR/generate-working-copy-states.py state 2 wc
   $ hg addremove --similarity 0
   adding content1_missing_content1-tracked
   adding content1_missing_content1-untracked
--- a/tests/test-tools.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-tools.t	Tue Jun 20 09:45:02 2017 -0400
@@ -44,10 +44,10 @@
 #endif
 
 #if no-windows
-  $ python $TESTDIR/seq.py 10 > bar
+  $ $PYTHON $TESTDIR/seq.py 10 > bar
 #else
 Convert CRLF -> LF for consistency
-  $ python $TESTDIR/seq.py 10 | sed "s/$//" > bar
+  $ $PYTHON $TESTDIR/seq.py 10 | sed "s/$//" > bar
 #endif
 
 #if unix-permissions symlink
--- a/tests/test-win32text.t	Thu Jun 15 14:22:39 2017 -0400
+++ b/tests/test-win32text.t	Tue Jun 20 09:45:02 2017 -0400
@@ -28,7 +28,7 @@
   updating to branch default
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ cp .hg/hgrc ../zoz/.hg
-  $ python unix2dos.py f
+  $ $PYTHON unix2dos.py f
 
 commit should fail
 
@@ -102,7 +102,7 @@
 
   $ mkdir d
   $ echo hello > d/f2
-  $ python unix2dos.py d/f2
+  $ $PYTHON unix2dos.py d/f2
   $ hg add d/f2
   $ hg ci -m 3
   attempt to commit or push text file(s) using CRLF line endings
@@ -181,7 +181,7 @@
   adding dupe/b (glob)
   adding dupe/c (glob)
   adding dupe/d (glob)
-  $ python unix2dos.py dupe/b dupe/c dupe/d
+  $ $PYTHON unix2dos.py dupe/b dupe/c dupe/d
   $ hg -R dupe ci -m a dupe/a
   $ hg -R dupe ci -m b/c dupe/[bc]
   $ hg -R dupe ci -m d dupe/d