Patchwork [2,of,2,pypy-support] tests: use $PYTHON instead of hardcoding python

login
register
mail settings
Submitter Augie Fackler
Date Oct. 15, 2014, 8:07 p.m.
Message ID <1eba40108f3f7e0c4c85.1413403657@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/6298/
State Accepted
Headers show

Comments

Augie Fackler - Oct. 15, 2014, 8:07 p.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1413401759 14400
#      Wed Oct 15 15:35:59 2014 -0400
# Node ID 1eba40108f3f7e0c4c8511cf7a18cc0df8de61b9
# Parent  b2d09c0ac9f97e5ce4aafb9702eb1158387a8045
tests: use $PYTHON instead of hardcoding python

This makes running the testsuite with pypy possible.
Pierre-Yves David - Oct. 15, 2014, 8:23 p.m.
On 10/15/2014 01:07 PM, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <raf@durin42.com>
> # Date 1413401759 14400
> #      Wed Oct 15 15:35:59 2014 -0400
> # Node ID 1eba40108f3f7e0c4c8511cf7a18cc0df8de61b9
> # Parent  b2d09c0ac9f97e5ce4aafb9702eb1158387a8045
> tests: use $PYTHON instead of hardcoding python

Sure, those two are pushed to the clowncopter.
Matt Mackall - Oct. 16, 2014, 7:37 p.m.
On Wed, 2014-10-15 at 16:07 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <raf@durin42.com>
> # Date 1413401759 14400
> #      Wed Oct 15 15:35:59 2014 -0400
> # Node ID 1eba40108f3f7e0c4c8511cf7a18cc0df8de61b9
> # Parent  b2d09c0ac9f97e5ce4aafb9702eb1158387a8045
> tests: use $PYTHON instead of hardcoding python
> 
> This makes running the testsuite with pypy possible.
> 
> diff --git a/tests/test-addremove-similar.t b/tests/test-addremove-similar.t
> --- a/tests/test-addremove-similar.t
> +++ b/tests/test-addremove-similar.t
> @@ -1,7 +1,7 @@
>    $ hg init rep; cd rep
>  
>    $ touch empty-file
> -  $ python -c 'for x in range(10000): print x' > large-file
> +  $ $PYTHON -c 'for x in range(10000): print x' > large-file

Two problems here:

- no check-code rule to prevent back-creep
- almost all of this should be switched to ">>>" anyway
Augie Fackler - Oct. 16, 2014, 7:37 p.m.
On Thu, Oct 16, 2014 at 3:37 PM, Matt Mackall <mpm@selenic.com> wrote:
> Two problems here:
>
> - no check-code rule to prevent back-creep
> - almost all of this should be switched to ">>>" anyway

I'll follow up with a check-code rule shortly.

Patch

diff --git a/tests/test-addremove-similar.t b/tests/test-addremove-similar.t
--- a/tests/test-addremove-similar.t
+++ b/tests/test-addremove-similar.t
@@ -1,7 +1,7 @@ 
   $ hg init rep; cd rep
 
   $ touch empty-file
-  $ python -c 'for x in range(10000): print x' > large-file
+  $ $PYTHON -c 'for x in range(10000): print x' > large-file
 
   $ hg addremove
   adding empty-file
@@ -10,7 +10,7 @@ 
   $ hg commit -m A
 
   $ rm large-file empty-file
-  $ python -c 'for x in range(10,10000): print x' > another-file
+  $ $PYTHON -c 'for x in range(10,10000): print x' > another-file
 
   $ hg addremove -s50
   adding another-file
@@ -34,8 +34,8 @@ 
 
   $ hg init rep2; cd rep2
 
-  $ python -c 'for x in range(10000): print x' > large-file
-  $ python -c 'for x in range(50): print x' > tiny-file
+  $ $PYTHON -c 'for x in range(10000): print x' > large-file
+  $ $PYTHON -c 'for x in range(50): print x' > tiny-file
 
   $ hg addremove
   adding large-file
@@ -43,7 +43,7 @@ 
 
   $ hg commit -m A
 
-  $ python -c 'for x in range(70): print x' > small-file
+  $ $PYTHON -c 'for x in range(70): print x' > small-file
   $ rm tiny-file
   $ rm large-file
 
diff --git a/tests/test-clone.t b/tests/test-clone.t
--- a/tests/test-clone.t
+++ b/tests/test-clone.t
@@ -10,7 +10,7 @@ 
 
 Create a non-inlined filelog:
 
-  $ python -c 'file("data1", "wb").write("".join("%s\n" % x for x in range(10000)))'
+  $ $PYTHON -c 'file("data1", "wb").write("".join("%s\n" % x for x in range(10000)))'
   $ for j in 0 1 2 3 4 5 6 7 8 9; do
   >   cat data1 >> b
   >   hg commit -m test
diff --git a/tests/test-contrib.t b/tests/test-contrib.t
--- a/tests/test-contrib.t
+++ b/tests/test-contrib.t
@@ -207,7 +207,7 @@ 
 
 binary file
 
-  $ python -c "f = file('binary-local', 'w'); f.write('\x00'); f.close()"
+  $ $PYTHON -c "f = file('binary-local', 'w'); f.write('\x00'); f.close()"
   $ cat orig >> binary-local
   $ python simplemerge -p binary-local base other
   warning: binary-local looks like a binary file.
diff --git a/tests/test-convert-git.t b/tests/test-convert-git.t
--- a/tests/test-convert-git.t
+++ b/tests/test-convert-git.t
@@ -297,7 +297,7 @@ 
   $ mkdir git-repo3
   $ cd git-repo3
   $ git init-db >/dev/null 2>/dev/null
-  $ python -c 'file("b", "wb").write("".join([chr(i) for i in range(256)])*16)'
+  $ $PYTHON -c 'file("b", "wb").write("".join([chr(i) for i in range(256)])*16)'
   $ git add b
   $ commit -a -m addbinary
   $ cd ..
@@ -314,7 +314,7 @@ 
   $ cd git-repo3-hg
   $ hg up -C
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ python -c 'print len(file("b", "rb").read())'
+  $ $PYTHON -c 'print len(file("b", "rb").read())'
   4096
   $ cd ..
 
diff --git a/tests/test-convert-hg-svn.t b/tests/test-convert-hg-svn.t
--- a/tests/test-convert-hg-svn.t
+++ b/tests/test-convert-hg-svn.t
@@ -6,9 +6,9 @@ 
 
   $ SVNREPOPATH=`pwd`/svn-repo
 #if windows
-  $ SVNREPOURL=file:///`python -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
+  $ SVNREPOURL=file:///`$PYTHON -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
 #else
-  $ SVNREPOURL=file://`python -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
+  $ SVNREPOURL=file://`$PYTHON -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
 #endif
 
   $ svnadmin create "$SVNREPOPATH"
diff --git a/tests/test-convert-mtn.t b/tests/test-convert-mtn.t
--- a/tests/test-convert-mtn.t
+++ b/tests/test-convert-mtn.t
@@ -43,7 +43,7 @@ 
   $ mkdir dir
   $ echo b > dir/b
   $ echo d > dir/d
-  $ python -c 'file("bin", "wb").write("a\\x00b")'
+  $ $PYTHON -c 'file("bin", "wb").write("a\\x00b")'
   $ echo c > c
   $ mtn add a dir/b dir/d c bin
   mtn: adding 'a' to workspace manifest
@@ -65,7 +65,7 @@ 
   $ echo b >> dir/b
   $ mtn drop c
   mtn: dropping 'c' from workspace manifest
-  $ python -c 'file("bin", "wb").write("b\\x00c")'
+  $ $PYTHON -c 'file("bin", "wb").write("b\\x00c")'
   $ mtn ci -m update1
   mtn: beginning commit on branch 'com.selenic.test'
   mtn: committed revision 51d0a982464573a2a2cf5ee2c9219c652aaebeff
diff --git a/tests/test-convert-p4-filetypes.t b/tests/test-convert-p4-filetypes.t
--- a/tests/test-convert-p4-filetypes.t
+++ b/tests/test-convert-p4-filetypes.t
@@ -52,7 +52,7 @@ 
   >          p4 add -t $T file_$T2
   >          ;;
   >       binary*)
-  >          python -c "file('file_$T2', 'wb').write('this is $T')"
+  >          $PYTHON -c "file('file_$T2', 'wb').write('this is $T')"
   >          p4 add -t $T file_$T2
   >          ;;
   >       *)
diff --git a/tests/test-convert-svn-move.t b/tests/test-convert-svn-move.t
--- a/tests/test-convert-svn-move.t
+++ b/tests/test-convert-svn-move.t
@@ -9,9 +9,9 @@ 
   $ svnadmin load -q svn-repo < "$TESTDIR/svn/move.svndump"
   $ SVNREPOPATH=`pwd`/svn-repo
 #if windows
-  $ SVNREPOURL=file:///`python -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
+  $ SVNREPOURL=file:///`$PYTHON -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
 #else
-  $ SVNREPOURL=file://`python -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
+  $ SVNREPOURL=file://`$PYTHON -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
 #endif
 
 Convert trunk and branches
diff --git a/tests/test-convert-svn-source.t b/tests/test-convert-svn-source.t
--- a/tests/test-convert-svn-source.t
+++ b/tests/test-convert-svn-source.t
@@ -10,9 +10,9 @@ 
   $ svnadmin create svn-repo
   $ SVNREPOPATH=`pwd`/svn-repo
 #if windows
-  $ SVNREPOURL=file:///`python -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
+  $ SVNREPOURL=file:///`$PYTHON -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
 #else
-  $ SVNREPOURL=file://`python -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
+  $ SVNREPOURL=file://`$PYTHON -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
 #endif
   $ INVALIDREVISIONID=svn:x2147622-4a9f-4db4-a8d3-13562ff547b2/proj%20B/mytrunk@1
   $ VALIDREVISIONID=svn:a2147622-4a9f-4db4-a8d3-13562ff547b2/proj%20B/mytrunk/mytrunk@1
diff --git a/tests/test-diff-newlines.t b/tests/test-diff-newlines.t
--- a/tests/test-diff-newlines.t
+++ b/tests/test-diff-newlines.t
@@ -1,6 +1,6 @@ 
   $ hg init
 
-  $ python -c 'file("a", "wb").write("confuse str.splitlines\nembedded\rnewline\n")'
+  $ $PYTHON -c 'file("a", "wb").write("confuse str.splitlines\nembedded\rnewline\n")'
   $ hg ci -Ama -d '1 0'
   adding a
 
diff --git a/tests/test-diff-upgrade.t b/tests/test-diff-upgrade.t
--- a/tests/test-diff-upgrade.t
+++ b/tests/test-diff-upgrade.t
@@ -14,7 +14,7 @@ 
 
   $ echo regular > regular
   $ echo rmregular > rmregular
-  $ python -c "file('bintoregular', 'wb').write('\0')"
+  $ $PYTHON -c "file('bintoregular', 'wb').write('\0')"
   $ touch rmempty
   $ echo exec > exec
   $ chmod +x exec
@@ -24,7 +24,7 @@ 
   $ echo unsetexec > unsetexec
   $ chmod +x unsetexec
   $ echo binary > binary
-  $ python -c "file('rmbinary', 'wb').write('\0')"
+  $ $PYTHON -c "file('rmbinary', 'wb').write('\0')"
   $ hg ci -Am addfiles
   adding binary
   adding bintoregular
@@ -48,8 +48,8 @@ 
   $ rm rmexec
   $ chmod +x setexec
   $ chmod -x unsetexec
-  $ python -c "file('binary', 'wb').write('\0\0')"
-  $ python -c "file('newbinary', 'wb').write('\0')"
+  $ $PYTHON -c "file('binary', 'wb').write('\0\0')"
+  $ $PYTHON -c "file('newbinary', 'wb').write('\0')"
   $ rm rmbinary
   $ hg addremove -s 0
   adding newbinary
diff --git a/tests/test-extension.t b/tests/test-extension.t
--- a/tests/test-extension.t
+++ b/tests/test-extension.t
@@ -729,7 +729,7 @@ 
   ** Extensions loaded: throw, older
 
 Declare the version as supporting this hg version, show regular bts link:
-  $ hgver=`python -c 'from mercurial import util; print util.version().split("+")[0]'`
+  $ hgver=`$PYTHON -c 'from mercurial import util; print util.version().split("+")[0]'`
   $ echo 'testedwith = """'"$hgver"'"""' >> throw.py
   $ rm -f throw.pyc throw.pyo
   $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
diff --git a/tests/test-glog.t b/tests/test-glog.t
--- a/tests/test-glog.t
+++ b/tests/test-glog.t
@@ -1631,7 +1631,7 @@ 
 
 Test glob expansion of pats
 
-  $ expandglobs=`python -c "import mercurial.util; \
+  $ expandglobs=`$PYTHON -c "import mercurial.util; \
   >   print mercurial.util.expandglobs and 'true' or 'false'"`
   $ if [ $expandglobs = "true" ]; then
   >    testlog 'a*';
diff --git a/tests/test-grep.t b/tests/test-grep.t
--- a/tests/test-grep.t
+++ b/tests/test-grep.t
@@ -110,7 +110,7 @@ 
 
 match in last "line" without newline
 
-  $ python -c 'fp = open("noeol", "wb"); fp.write("no infinite loop"); fp.close();'
+  $ $PYTHON -c 'fp = open("noeol", "wb"); fp.write("no infinite loop"); fp.close();'
   $ hg ci -Amnoeol
   adding noeol
   $ hg grep loop
diff --git a/tests/test-hgrc.t b/tests/test-hgrc.t
--- a/tests/test-hgrc.t
+++ b/tests/test-hgrc.t
@@ -58,7 +58,7 @@ 
   unexpected leading whitespace
   [255]
 
-  $ python -c "print '[foo]\nbar = a\n b\n c \n  de\n fg \nbaz = bif cb \n'" \
+  $ $PYTHON -c "print '[foo]\nbar = a\n b\n c \n  de\n fg \nbaz = bif cb \n'" \
   > > $HGRC
   $ hg showconfig foo
   foo.bar=a\nb\nc\nde\nfg
diff --git a/tests/test-hgweb-commands.t b/tests/test-hgweb-commands.t
--- a/tests/test-hgweb-commands.t
+++ b/tests/test-hgweb-commands.t
@@ -2034,7 +2034,7 @@ 
 commit message with Japanese Kanji 'Noh', which ends with '\x5c'
 
   $ echo foo >> foo
-  $ HGENCODING=cp932 hg ci -m `python -c 'print("\x94\x5c")'`
+  $ HGENCODING=cp932 hg ci -m `$PYTHON -c 'print("\x94\x5c")'`
 
 Graph json escape of multibyte character
 
diff --git a/tests/test-hgweb.t b/tests/test-hgweb.t
--- a/tests/test-hgweb.t
+++ b/tests/test-hgweb.t
@@ -325,7 +325,7 @@ 
 
 Test the access/error files are opened in append mode
 
-  $ python -c "print len(file('access.log').readlines()), 'log lines written'"
+  $ $PYTHON -c "print len(file('access.log').readlines()), 'log lines written'"
   14 log lines written
 
 static file
diff --git a/tests/test-highlight.t b/tests/test-highlight.t
--- a/tests/test-highlight.t
+++ b/tests/test-highlight.t
@@ -577,7 +577,7 @@ 
   $ cd ..
   $ hg init eucjp
   $ cd eucjp
-  $ python -c 'print("\265\376")' >> eucjp.txt  # Japanese kanji "Kyo"
+  $ $PYTHON -c 'print("\265\376")' >> eucjp.txt  # Japanese kanji "Kyo"
   $ hg ci -Ama
   adding eucjp.txt
   $ hgserveget () {
diff --git a/tests/test-import-bypass.t b/tests/test-import-bypass.t
--- a/tests/test-import-bypass.t
+++ b/tests/test-import-bypass.t
@@ -143,7 +143,7 @@ 
 (this also tests that editor is not invoked for '--bypass', if the
 commit message is explicitly specified, regardless of '--edit')
 
-  $ python -c 'file("a", "wb").write("a\r\n")'
+  $ $PYTHON -c 'file("a", "wb").write("a\r\n")'
   $ hg ci -m makeacrlf
   $ HGEDITOR=cat hg import -m 'should fail because of eol' --edit --bypass ../test.diff
   applying ../test.diff
diff --git a/tests/test-import-eol.t b/tests/test-import-eol.t
--- a/tests/test-import-eol.t
+++ b/tests/test-import-eol.t
@@ -25,7 +25,7 @@ 
 
 Test different --eol values
 
-  $ python -c 'file("a", "wb").write("a\nbbb\ncc\n\nd\ne")'
+  $ $PYTHON -c 'file("a", "wb").write("a\nbbb\ncc\n\nd\ne")'
   $ hg ci -Am adda
   adding .hgignore
   adding a
@@ -89,7 +89,7 @@ 
 
 auto EOL on CRLF file
 
-  $ python -c 'file("a", "wb").write("a\r\nbbb\r\ncc\r\n\r\nd\r\ne")'
+  $ $PYTHON -c 'file("a", "wb").write("a\r\nbbb\r\ncc\r\n\r\nd\r\ne")'
   $ hg commit -m 'switch EOLs in a'
   $ hg --traceback --config patch.eol='auto' import eol.diff
   applying eol.diff
@@ -105,11 +105,11 @@ 
 
 auto EOL on new file or source without any EOL
 
-  $ python -c 'file("noeol", "wb").write("noeol")'
+  $ $PYTHON -c 'file("noeol", "wb").write("noeol")'
   $ hg add noeol
   $ hg commit -m 'add noeol'
-  $ python -c 'file("noeol", "wb").write("noeol\r\nnoeol\n")'
-  $ python -c 'file("neweol", "wb").write("neweol\nneweol\r\n")'
+  $ $PYTHON -c 'file("noeol", "wb").write("noeol\r\nnoeol\n")'
+  $ $PYTHON -c 'file("neweol", "wb").write("neweol\nneweol\r\n")'
   $ hg add neweol
   $ hg diff --git > noeol.diff
   $ hg revert --no-backup noeol neweol
@@ -127,10 +127,10 @@ 
 
 Test --eol and binary patches
 
-  $ python -c 'file("b", "wb").write("a\x00\nb\r\nd")'
+  $ $PYTHON -c 'file("b", "wb").write("a\x00\nb\r\nd")'
   $ hg ci -Am addb
   adding b
-  $ python -c 'file("b", "wb").write("a\x00\nc\r\nd")'
+  $ $PYTHON -c 'file("b", "wb").write("a\x00\nc\r\nd")'
   $ hg diff --git > bin.diff
   $ hg revert --no-backup b
 
diff --git a/tests/test-import.t b/tests/test-import.t
--- a/tests/test-import.t
+++ b/tests/test-import.t
@@ -589,7 +589,7 @@ 
   $ hg init binaryremoval
   $ cd binaryremoval
   $ echo a > a
-  $ python -c "file('b', 'wb').write('a\x00b')"
+  $ $PYTHON -c "file('b', 'wb').write('a\x00b')"
   $ hg ci -Am addall
   adding a
   adding b
diff --git a/tests/test-module-imports.t b/tests/test-module-imports.t
--- a/tests/test-module-imports.t
+++ b/tests/test-module-imports.t
@@ -1,6 +1,6 @@ 
 This code uses the ast module, which was new in 2.6, so we'll skip
 this test on anything earlier.
-  $ python -c 'import sys ; assert sys.version_info >= (2, 6)' || exit 80
+  $ $PYTHON -c 'import sys ; assert sys.version_info >= (2, 6)' || exit 80
 
   $ import_checker="$TESTDIR"/../contrib/import-checker.py
 Run the doctests from the import checker, and make sure
diff --git a/tests/test-mq-eol.t b/tests/test-mq-eol.t
--- a/tests/test-mq-eol.t
+++ b/tests/test-mq-eol.t
@@ -42,7 +42,7 @@ 
 
 Test different --eol values
 
-  $ python -c 'file("a", "wb").write("a\nb\nc\nd\ne")'
+  $ $PYTHON -c 'file("a", "wb").write("a\nb\nc\nd\ne")'
   $ hg ci -Am adda
   adding .hgignore
   adding a
@@ -150,15 +150,15 @@ 
 
   $ hg init testeol
   $ cd testeol
-  $ python -c "file('a', 'wb').write('1\r\n2\r\n3\r\n4')"
+  $ $PYTHON -c "file('a', 'wb').write('1\r\n2\r\n3\r\n4')"
   $ hg ci -Am adda
   adding a
-  $ python -c "file('a', 'wb').write('1\r\n2\r\n33\r\n4')"
+  $ $PYTHON -c "file('a', 'wb').write('1\r\n2\r\n33\r\n4')"
   $ hg qnew patch1
   $ hg qpop
   popping patch1
   patch queue now empty
-  $ python -c "file('a', 'wb').write('1\r\n22\r\n33\r\n4')"
+  $ $PYTHON -c "file('a', 'wb').write('1\r\n22\r\n33\r\n4')"
   $ hg ci -m changea
 
   $ hg --config 'patch.eol=LF' qpush
diff --git a/tests/test-mq-qpush-fail.t b/tests/test-mq-qpush-fail.t
--- a/tests/test-mq-qpush-fail.t
+++ b/tests/test-mq-qpush-fail.t
@@ -31,7 +31,7 @@ 
   popping patch2
   popping patch1
   patch queue now empty
-  $ python -c 'print "\xe9"' > message
+  $ $PYTHON -c 'print "\xe9"' > message
   $ cat .hg/patches/bad-patch >> message
   $ mv message .hg/patches/bad-patch
   $ hg qpush -a && echo 'qpush succeeded?!'
diff --git a/tests/test-mq-subrepo-svn.t b/tests/test-mq-subrepo-svn.t
--- a/tests/test-mq-subrepo-svn.t
+++ b/tests/test-mq-subrepo-svn.t
@@ -19,9 +19,9 @@ 
 
   $ SVNREPOPATH=`pwd`/svn-repo-2499/project
 #if windows
-  $ SVNREPOURL=file:///`python -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
+  $ SVNREPOURL=file:///`$PYTHON -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
 #else
-  $ SVNREPOURL=file://`python -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
+  $ SVNREPOURL=file://`$PYTHON -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
 #endif
 
   $ mkdir -p svn-project-2499/trunk
diff --git a/tests/test-notify-changegroup.t b/tests/test-notify-changegroup.t
--- a/tests/test-notify-changegroup.t
+++ b/tests/test-notify-changegroup.t
@@ -39,7 +39,7 @@ 
 push
 
   $ hg --traceback --cwd b push ../a 2>&1 |
-  >     python -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
+  >     $PYTHON -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
   pushing to ../a
   searching for changes
   adding changesets
@@ -92,7 +92,7 @@ 
 unbundle with correct source
 
   $ hg --config notify.sources=unbundle --cwd a unbundle ../test.hg 2>&1 |
-  >     python -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
+  >     $PYTHON -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
   adding changesets
   adding manifests
   adding file changes
@@ -167,7 +167,7 @@ 
 push
 
   $ hg --traceback --cwd b --config notify.fromauthor=True push ../a 2>&1 |
-  >     python -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
+  >     $PYTHON -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
   pushing to ../a
   searching for changes
   adding changesets
diff --git a/tests/test-notify.t b/tests/test-notify.t
--- a/tests/test-notify.t
+++ b/tests/test-notify.t
@@ -176,7 +176,7 @@ 
 pull (minimal config)
 
   $ hg --traceback --cwd b pull ../a | \
-  >   python -c 'import sys,re; print re.sub("\n[\t ]", " ", sys.stdin.read()),'
+  >   $PYTHON -c 'import sys,re; print re.sub("\n[\t ]", " ", sys.stdin.read()),'
   pulling from ../a
   searching for changes
   adding changesets
@@ -229,7 +229,7 @@ 
   $ hg --cwd b rollback
   repository tip rolled back to revision 0 (undo pull)
   $ hg --traceback --cwd b pull ../a  | \
-  >   python -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
+  >   $PYTHON -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
   pulling from ../a
   searching for changes
   adding changesets
@@ -273,7 +273,7 @@ 
   $ hg --cwd b rollback
   repository tip rolled back to revision 0 (undo pull)
   $ hg --traceback --cwd b pull ../a | \
-  >   python -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
+  >   $PYTHON -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
   pulling from ../a
   searching for changes
   adding changesets
@@ -322,7 +322,7 @@ 
   $ hg ci -m merge -d '3 0'
   $ cd ..
   $ hg --traceback --cwd b pull ../a | \
-  >   python -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
+  >   $PYTHON -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
   pulling from ../a
   searching for changes
   adding changesets
@@ -378,9 +378,9 @@ 
   > EOF
   $ echo a >> a/a
   $ hg --cwd a --encoding utf-8 commit -A -d '0 0' \
-  >   -m `python -c 'print "\xc3\xa0\xc3\xa1\xc3\xa2\xc3\xa3\xc3\xa4"'`
+  >   -m `$PYTHON -c 'print "\xc3\xa0\xc3\xa1\xc3\xa2\xc3\xa3\xc3\xa4"'`
   $ hg --traceback --cwd b --encoding utf-8 pull ../a | \
-  >   python -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
+  >   $PYTHON -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
   pulling from ../a
   searching for changes
   adding changesets
@@ -424,7 +424,7 @@ 
   > test = False
   > mbox = mbox
   > EOF
-  $ python -c 'file("a/a", "ab").write("no" * 500 + "\n")'
+  $ $PYTHON -c 'file("a/a", "ab").write("no" * 500 + "\n")'
   $ hg --cwd a commit -A -m "long line"
   $ hg --traceback --cwd b pull ../a
   pulling from ../a
@@ -435,7 +435,7 @@ 
   added 1 changesets with 1 changes to 1 files
   notify: sending 2 subscribers 1 changes
   (run 'hg update' to get a working copy)
-  $ python -c 'import sys,re; print re.sub("\n\t", " ", file("b/mbox").read()),'
+  $ $PYTHON -c 'import sys,re; print re.sub("\n\t", " ", file("b/mbox").read()),'
   From test@test.com ... ... .. ..:..:.. .... (re)
   Content-Type: text/plain; charset="us-ascii"
   MIME-Version: 1.0
@@ -501,7 +501,7 @@ 
   $ echo a >> a/a
   $ hg --cwd a ci -m test -d '1 0'
   $ hg --traceback --cwd b pull ../a | \
-  >   python -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
+  >   $PYTHON -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
   pulling from ../a
   searching for changes
   adding changesets
@@ -531,7 +531,7 @@ 
   $ echo a >> a/a
   $ hg --cwd a ci -m test -d '1 0'
   $ hg --traceback --cwd b pull ../a | \
-  >   python -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
+  >   $PYTHON -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
   pulling from ../a
   searching for changes
   adding changesets
diff --git a/tests/test-patchbomb.t b/tests/test-patchbomb.t
--- a/tests/test-patchbomb.t
+++ b/tests/test-patchbomb.t
@@ -270,7 +270,7 @@ 
   --===*=-- (glob)
 
 utf-8 patch:
-  $ python -c 'fp = open("utf", "wb"); fp.write("h\xC3\xB6mma!\n"); fp.close();'
+  $ $PYTHON -c 'fp = open("utf", "wb"); fp.write("h\xC3\xB6mma!\n"); fp.close();'
   $ hg commit -A -d '4 0' -m 'utf-8 content'
   adding description
   adding utf
@@ -354,7 +354,7 @@ 
   QEAgLTAsMCArMSwxIEBACitow7ZtbWEhCg==
   
   
-  $ python -c 'print open("mbox").read().split("\n\n")[1].decode("base64")'
+  $ $PYTHON -c 'print open("mbox").read().split("\n\n")[1].decode("base64")'
   # HG changeset patch
   # User test
   # Date 4 0
@@ -379,7 +379,7 @@ 
   $ rm mbox
 
 mime encoded mbox (quoted-printable):
-  $ python -c 'fp = open("long", "wb"); fp.write("%s\nfoo\n\nbar\n" % ("x" * 1024)); fp.close();'
+  $ $PYTHON -c 'fp = open("long", "wb"); fp.write("%s\nfoo\n\nbar\n" % ("x" * 1024)); fp.close();'
   $ hg commit -A -d '4 0' -m 'long line'
   adding long
 
@@ -493,7 +493,7 @@ 
   $ rm mbox
 
 iso-8859-1 patch:
-  $ python -c 'fp = open("isolatin", "wb"); fp.write("h\xF6mma!\n"); fp.close();'
+  $ $PYTHON -c 'fp = open("isolatin", "wb"); fp.write("h\xF6mma!\n"); fp.close();'
   $ hg commit -A -d '5 0' -m 'isolatin 8-bit encoding'
   adding isolatin
 
@@ -2237,7 +2237,7 @@ 
   
 
 test multi-byte domain parsing:
-  $ UUML=`python -c 'import sys; sys.stdout.write("\374")'`
+  $ UUML=`$PYTHON -c 'import sys; sys.stdout.write("\374")'`
   $ HGENCODING=iso-8859-1
   $ export HGENCODING
   $ hg email --date '1980-1-1 0:1' -m tmp.mbox -f quux -t "bar@${UUML}nicode.com" -s test -r 0
diff --git a/tests/test-pull.t b/tests/test-pull.t
--- a/tests/test-pull.t
+++ b/tests/test-pull.t
@@ -81,12 +81,12 @@ 
 It's tricky to make file:// URLs working on every platform with
 regular shell commands.
 
-  $ URL=`python -c "import os; print 'file://foobar' + ('/' + os.getcwd().replace(os.sep, '/')).replace('//', '/') + '/../test'"`
+  $ URL=`$PYTHON -c "import os; print 'file://foobar' + ('/' + os.getcwd().replace(os.sep, '/')).replace('//', '/') + '/../test'"`
   $ hg pull -q "$URL"
   abort: file:// URLs can only refer to localhost
   [255]
 
-  $ URL=`python -c "import os; print 'file://localhost' + ('/' + os.getcwd().replace(os.sep, '/')).replace('//', '/') + '/../test'"`
+  $ URL=`$PYTHON -c "import os; print 'file://localhost' + ('/' + os.getcwd().replace(os.sep, '/')).replace('//', '/') + '/../test'"`
   $ hg pull -q "$URL"
 
   $ cd ..
diff --git a/tests/test-relink.t b/tests/test-relink.t
--- a/tests/test-relink.t
+++ b/tests/test-relink.t
@@ -47,7 +47,7 @@ 
 
 Test files are read in binary mode
 
-  $ python -c "file('.hg/store/data/dummy.i', 'wb').write('a\r\nb\n')"
+  $ $PYTHON -c "file('.hg/store/data/dummy.i', 'wb').write('a\r\nb\n')"
   $ cd ..
 
 
@@ -65,7 +65,7 @@ 
   $ echo b >> b
   $ hg ci -m changeb
   created new head
-  $ python -c "file('.hg/store/data/dummy.i', 'wb').write('a\nb\r\n')"
+  $ $PYTHON -c "file('.hg/store/data/dummy.i', 'wb').write('a\nb\r\n')"
 
 
 relink
diff --git a/tests/test-subrepo-svn.t b/tests/test-subrepo-svn.t
--- a/tests/test-subrepo-svn.t
+++ b/tests/test-subrepo-svn.t
@@ -2,9 +2,9 @@ 
 
   $ SVNREPOPATH=`pwd`/svn-repo
 #if windows
-  $ SVNREPOURL=file:///`python -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
+  $ SVNREPOURL=file:///`$PYTHON -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
 #else
-  $ SVNREPOURL=file://`python -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
+  $ SVNREPOURL=file://`$PYTHON -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"`
 #endif
 
 create subversion repo
@@ -242,7 +242,7 @@ 
 
 verify subrepo is contained within the repo directory
 
-  $ python -c "import os.path; print os.path.exists('s')"
+  $ $PYTHON -c "import os.path; print os.path.exists('s')"
   True
 
 update to nullrev (must delete the subrepo)
diff --git a/tests/test-transplant.t b/tests/test-transplant.t
--- a/tests/test-transplant.t
+++ b/tests/test-transplant.t
@@ -668,7 +668,7 @@ 
   $ cd twin2
   $ echo '[patch]' >> .hg/hgrc
   $ echo 'eol = crlf' >> .hg/hgrc
-  $ python -c "file('b', 'wb').write('b\r\nb\r\n')"
+  $ $PYTHON -c "file('b', 'wb').write('b\r\nb\r\n')"
   $ hg ci -Am addb
   adding b
   $ hg transplant -s ../twin1 tip
diff --git a/tests/test-walk.t b/tests/test-walk.t
--- a/tests/test-walk.t
+++ b/tests/test-walk.t
@@ -310,11 +310,11 @@ 
 
 Test listfile and listfile0
 
-  $ python -c "file('listfile0', 'wb').write('fenugreek\0new\0')"
+  $ $PYTHON -c "file('listfile0', 'wb').write('fenugreek\0new\0')"
   $ hg debugwalk -I 'listfile0:listfile0'
   f  fenugreek  fenugreek
   f  new        new
-  $ python -c "file('listfile', 'wb').write('fenugreek\nnew\r\nmammals/skunk\n')"
+  $ $PYTHON -c "file('listfile', 'wb').write('fenugreek\nnew\r\nmammals/skunk\n')"
   $ hg debugwalk -I 'listfile:listfile'
   f  fenugreek      fenugreek
   f  mammals/skunk  mammals/skunk
@@ -336,7 +336,7 @@ 
 
   $ cd t
   $ echo fennel > overflow.list
-  $ python -c "for i in xrange(20000 / 100): print 'x' * 100" >> overflow.list
+  $ $PYTHON -c "for i in xrange(20000 / 100): print 'x' * 100" >> overflow.list
   $ echo fenugreek >> overflow.list
   $ hg debugwalk 'listfile:overflow.list' 2>&1 | grep -v '^xxx'
   f  fennel     fennel     exact
diff --git a/tests/test-win32text.t b/tests/test-win32text.t
--- a/tests/test-win32text.t
+++ b/tests/test-win32text.t
@@ -118,7 +118,7 @@ 
   $ hg rem f
   $ hg ci -m 4
 
-  $ python -c 'file("bin", "wb").write("hello\x00\x0D\x0A")'
+  $ $PYTHON -c 'file("bin", "wb").write("hello\x00\x0D\x0A")'
   $ hg add bin
   $ hg ci -m 5
   $ hg log -v
@@ -342,7 +342,7 @@ 
   
   $ rm .hg/hgrc
   $ (echo some; echo text) > f3
-  $ python -c 'file("f4.bat", "wb").write("rem empty\x0D\x0A")'
+  $ $PYTHON -c 'file("f4.bat", "wb").write("rem empty\x0D\x0A")'
   $ hg add f3 f4.bat
   $ hg ci -m 6
   $ cat bin
@@ -395,7 +395,7 @@ 
   $ cat f4.bat
   rem empty\r (esc)
 
-  $ python -c 'file("f5.sh", "wb").write("# empty\x0D\x0A")'
+  $ $PYTHON -c 'file("f5.sh", "wb").write("# empty\x0D\x0A")'
   $ hg add f5.sh
   $ hg ci -m 7
   $ cat f5.sh