##// END OF EJS Templates
tests: clean up many print statements to be print functions instead...
Augie Fackler -
r33687:24849d53 default
parent child Browse files
Show More
@@ -345,7 +345,7 b' The default interface is text'
345 345 > $PYTHON <<EOF
346 346 > from mercurial import hg, ui;\
347 347 > repo = hg.repository(ui.ui.load(), ".");\
348 > print repo.ui.interface("chunkselector")
348 > print(repo.ui.interface("chunkselector"))
349 349 > EOF
350 350 > }
351 351 $ chunkselectorinterface
@@ -90,7 +90,7 b' now test that we fixed the bug for all s'
90 90 > f.close()
91 91 >
92 92 > def printfiles(repo, rev):
93 > print "revision %s files: %s" % (rev, repo[rev].files())
93 > print("revision %s files: %s" % (rev, repo[rev].files()))
94 94 >
95 95 > repo = hg.repository(ui.ui.load(), '.')
96 96 > assert len(repo) == 6, \
@@ -99,14 +99,14 b' now test that we fixed the bug for all s'
99 99 > replacebyte("bugfix", "u")
100 100 > sleep(2)
101 101 > try:
102 > print "PRE: len(repo): %d" % len(repo)
102 > print("PRE: len(repo): %d" % len(repo))
103 103 > wlock = repo.wlock()
104 104 > lock = repo.lock()
105 105 > replacebyte("file1", "x")
106 106 > repo.commit(text="x", user="test", date=(0, 0))
107 107 > replacebyte("file1", "y")
108 108 > repo.commit(text="y", user="test", date=(0, 0))
109 > print "POST: len(repo): %d" % len(repo)
109 > print("POST: len(repo): %d" % len(repo))
110 110 > finally:
111 111 > lock.release()
112 112 > wlock.release()
@@ -213,32 +213,32 b''
213 213 [1]
214 214
215 215 $ cat > ./map-inside-gettext.py <<EOF
216 > print _("map inside gettext %s" % v)
216 > print(_("map inside gettext %s" % v))
217 217 >
218 > print _("concatenating " " by " " space %s" % v)
219 > print _("concatenating " + " by " + " '+' %s" % v)
218 > print(_("concatenating " " by " " space %s" % v))
219 > print(_("concatenating " + " by " + " '+' %s" % v))
220 220 >
221 > print _("mapping operation in different line %s"
222 > % v)
221 > print(_("mapping operation in different line %s"
222 > % v))
223 223 >
224 > print _(
225 > "leading spaces inside of '(' %s" % v)
224 > print(_(
225 > "leading spaces inside of '(' %s" % v))
226 226 > EOF
227 227 $ "$check_code" ./map-inside-gettext.py
228 228 ./map-inside-gettext.py:1:
229 > print _("map inside gettext %s" % v)
229 > print(_("map inside gettext %s" % v))
230 230 don't use % inside _()
231 231 ./map-inside-gettext.py:3:
232 > print _("concatenating " " by " " space %s" % v)
232 > print(_("concatenating " " by " " space %s" % v))
233 233 don't use % inside _()
234 234 ./map-inside-gettext.py:4:
235 > print _("concatenating " + " by " + " '+' %s" % v)
235 > print(_("concatenating " + " by " + " '+' %s" % v))
236 236 don't use % inside _()
237 237 ./map-inside-gettext.py:6:
238 > print _("mapping operation in different line %s"
238 > print(_("mapping operation in different line %s"
239 239 don't use % inside _()
240 240 ./map-inside-gettext.py:9:
241 > print _(
241 > print(_(
242 242 don't use % inside _()
243 243 [1]
244 244
@@ -12,10 +12,10 b''
12 12 $ echo "convert = " >> $HGRCPATH
13 13 $ cat > cvshooks.py <<EOF
14 14 > def cvslog(ui,repo,hooktype,log):
15 > print "%s hook: %d entries"%(hooktype,len(log))
15 > print("%s hook: %d entries"%(hooktype,len(log)))
16 16 >
17 17 > def cvschangesets(ui,repo,hooktype,changesets):
18 > print "%s hook: %d changesets"%(hooktype,len(changesets))
18 > print("%s hook: %d changesets"%(hooktype,len(changesets)))
19 19 > EOF
20 20 $ hookpath=`pwd`
21 21 $ cat <<EOF >> $HGRCPATH
@@ -16,7 +16,7 b' Set up helpers'
16 16 > except ImportError:
17 17 > pass
18 18 > (old, new) = sys.argv[1] == 'LF' and ('\n', '\r\n') or ('\r\n', '\n')
19 > print "%% switching encoding from %r to %r" % (old, new)
19 > print("%% switching encoding from %r to %r" % (old, new))
20 20 > for path in sys.argv[2:]:
21 21 > data = file(path, 'rb').read()
22 22 > data = data.replace(old, new)
@@ -75,13 +75,13 b' Check that extensions are loaded in phas'
75 75 $ cat > foo.py <<EOF
76 76 > import os
77 77 > name = os.path.basename(__file__).rsplit('.', 1)[0]
78 > print "1) %s imported" % name
78 > print("1) %s imported" % name)
79 79 > def uisetup(ui):
80 > print "2) %s uisetup" % name
80 > print("2) %s uisetup" % name)
81 81 > def extsetup():
82 > print "3) %s extsetup" % name
82 > print("3) %s extsetup" % name)
83 83 > def reposetup(ui, repo):
84 > print "4) %s reposetup" % name
84 > print("4) %s reposetup" % name)
85 85 >
86 86 > # custom predicate to check registration of functions at loading
87 87 > from mercurial import (
@@ -172,7 +172,7 b' Check "from __future__ import absolute_i'
172 172 $ cat > loadabs.py <<EOF
173 173 > import mod.ambigabs as ambigabs
174 174 > def extsetup():
175 > print 'ambigabs.s=%s' % ambigabs.s
175 > print('ambigabs.s=%s' % ambigabs.s)
176 176 > EOF
177 177 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadabs=loadabs.py root)
178 178 ambigabs.s=libroot/ambig.py
@@ -186,7 +186,7 b' Check "from __future__ import absolute_i'
186 186 $ cat > loadrel.py <<EOF
187 187 > import mod.ambigrel as ambigrel
188 188 > def extsetup():
189 > print 'ambigrel.s=%s' % ambigrel.s
189 > print('ambigrel.s=%s' % ambigrel.s)
190 190 > EOF
191 191 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadrel=loadrel.py root)
192 192 ambigrel.s=libroot/mod/ambig.py
@@ -2,8 +2,9 b" This test makes sure that we don't mark "
2 2 when we do a merge.
3 3
4 4 $ cat <<EOF > merge
5 > from __future__ import print_function
5 6 > import sys, os
6 > print "merging for", os.path.basename(sys.argv[1])
7 > print("merging for", os.path.basename(sys.argv[1]))
7 8 > EOF
8 9 $ HGMERGE="$PYTHON ../merge"; export HGMERGE
9 10
@@ -1633,7 +1633,7 b' Test multiple --include/--exclude/paths'
1633 1633 Test glob expansion of pats
1634 1634
1635 1635 $ expandglobs=`$PYTHON -c "import mercurial.util; \
1636 > print mercurial.util.expandglobs and 'true' or 'false'"`
1636 > print(mercurial.util.expandglobs and 'true' or 'false')"`
1637 1637 $ if [ $expandglobs = "true" ]; then
1638 1638 > testlog 'a*';
1639 1639 > else
@@ -1,11 +1,12 b''
1 1 #require hardlink
2 2
3 3 $ cat > nlinks.py <<EOF
4 > from __future__ import print_function
4 5 > import sys
5 6 > from mercurial import util
6 7 > for f in sorted(sys.stdin.readlines()):
7 8 > f = f[:-1]
8 > print util.nlinks(f), f
9 > print(util.nlinks(f), f)
9 10 > EOF
10 11
11 12 $ nlinksdir()
@@ -1709,7 +1709,7 b' such str.lower().'
1709 1709
1710 1710 $ $PYTHON <<EOF | sh
1711 1711 > upper = "\x8bL\x98^"
1712 > print "hg --encoding cp932 help -e ambiguous.%s" % upper
1712 > print("hg --encoding cp932 help -e ambiguous.%s" % upper)
1713 1713 > EOF
1714 1714 \x8bL\x98^ (esc)
1715 1715 ----
@@ -1719,7 +1719,7 b' such str.lower().'
1719 1719
1720 1720 $ $PYTHON <<EOF | sh
1721 1721 > lower = "\x8bl\x98^"
1722 > print "hg --encoding cp932 help -e ambiguous.%s" % lower
1722 > print("hg --encoding cp932 help -e ambiguous.%s" % lower)
1723 1723 > EOF
1724 1724 \x8bl\x98^ (esc)
1725 1725 ----
@@ -409,6 +409,7 b' preoutgoing hook can prevent outgoing ch'
409 409 $ cd "$TESTTMP/b"
410 410
411 411 $ cat > hooktests.py <<EOF
412 > from __future__ import print_function
412 413 > from mercurial import error
413 414 >
414 415 > uncallable = 0
@@ -418,9 +419,9 b' preoutgoing hook can prevent outgoing ch'
418 419 > args.pop('repo', None)
419 420 > a = list(args.items())
420 421 > a.sort()
421 > print 'hook args:'
422 > print('hook args:')
422 423 > for k, v in a:
423 > print ' ', k, v
424 > print(' ', k, v)
424 425 >
425 426 > def passhook(**args):
426 427 > printargs(args)
@@ -445,7 +446,7 b' preoutgoing hook can prevent outgoing ch'
445 446 > ui.note('verbose output from hook\n')
446 447 >
447 448 > def printtags(ui, repo, **args):
448 > print sorted(repo.tags())
449 > print(sorted(repo.tags()))
449 450 >
450 451 > class container:
451 452 > unreachable = 1
@@ -630,7 +631,7 b' make sure --traceback works'
630 631
631 632 $ cat > hookext.py <<EOF
632 633 > def autohook(**args):
633 > print "Automatically installed hook"
634 > print("Automatically installed hook")
634 635 >
635 636 > def reposetup(ui, repo):
636 637 > repo.ui.setconfig("hooks", "commit.auto", autohook)
@@ -667,7 +668,7 b' test python hook configured with python:'
667 668 $ cd hooks
668 669 $ cat > testhooks.py <<EOF
669 670 > def testhook(**args):
670 > print 'hook works'
671 > print('hook works')
671 672 > EOF
672 673 $ echo '[hooks]' > ../repo/.hg/hgrc
673 674 $ echo "pre-commit.test = python:`pwd`/testhooks.py:testhook" >> ../repo/.hg/hgrc
@@ -25,13 +25,13 b' just in case somebody has a strange $TMP'
25 25 > allnames.sort()
26 26 > for name in allnames:
27 27 > suffix = name in isdir and '/' or ''
28 > print '%05o %s%s' % (os.lstat(name).st_mode & 07777, name, suffix)
28 > print('%05o %s%s' % (os.lstat(name).st_mode & 07777, name, suffix))
29 29 > EOF
30 30
31 31 $ cat >mode.py <<EOF
32 32 > import sys
33 33 > import os
34 > print '%05o' % os.lstat(sys.argv[1]).st_mode
34 > print('%05o' % os.lstat(sys.argv[1]).st_mode)
35 35 > EOF
36 36
37 37 $ umask 077
@@ -8,7 +8,7 b' A script to generate nasty diff worst-ca'
8 8 > print
9 9 > if random.randint(0, 100) >= 50:
10 10 > x += 1
11 > print hex(x)
11 > print(hex(x))
12 12 > EOF
13 13
14 14 $ hg init a
@@ -96,7 +96,7 b' Portable way to print file permissions:'
96 96 > #!$PYTHON
97 97 > import sys, os
98 98 > path = sys.argv[1]
99 > print '%03o' % (os.lstat(path).st_mode & 0777)
99 > print('%03o' % (os.lstat(path).st_mode & 0777))
100 100 > EOF
101 101 $ chmod +x ls-l.py
102 102
@@ -1793,7 +1793,7 b' test -u/-k for problematic encoding'
1793 1793 $ cd problematicencoding
1794 1794
1795 1795 $ $PYTHON > setup.sh <<EOF
1796 > print u'''
1796 > print(u'''
1797 1797 > echo a > text
1798 1798 > hg add text
1799 1799 > hg --encoding utf-8 commit -u '\u30A2' -m none
@@ -1803,13 +1803,13 b' test -u/-k for problematic encoding'
1803 1803 > hg --encoding utf-8 commit -u none -m '\u30A2'
1804 1804 > echo d > text
1805 1805 > hg --encoding utf-8 commit -u none -m '\u30C2'
1806 > '''.encode('utf-8')
1806 > '''.encode('utf-8'))
1807 1807 > EOF
1808 1808 $ sh < setup.sh
1809 1809
1810 1810 test in problematic encoding
1811 1811 $ $PYTHON > test.sh <<EOF
1812 > print u'''
1812 > print(u'''
1813 1813 > hg --encoding cp932 log --template '{rev}\\n' -u '\u30A2'
1814 1814 > echo ====
1815 1815 > hg --encoding cp932 log --template '{rev}\\n' -u '\u30C2'
@@ -1817,7 +1817,7 b' test in problematic encoding'
1817 1817 > hg --encoding cp932 log --template '{rev}\\n' -k '\u30A2'
1818 1818 > echo ====
1819 1819 > hg --encoding cp932 log --template '{rev}\\n' -k '\u30C2'
1820 > '''.encode('cp932')
1820 > '''.encode('cp932'))
1821 1821 > EOF
1822 1822 $ sh < test.sh
1823 1823 0
@@ -1,5 +1,6 b''
1 1 $ cat > echo.py <<EOF
2 2 > #!$PYTHON
3 > from __future__ import print_function
3 4 > import os, sys
4 5 > try:
5 6 > import msvcrt
@@ -9,7 +10,7 b''
9 10 > pass
10 11 >
11 12 > for k in ('HG_FILE', 'HG_MY_ISLINK', 'HG_OTHER_ISLINK', 'HG_BASE_ISLINK'):
12 > print k, os.environ[k]
13 > print(k, os.environ[k])
13 14 > EOF
14 15
15 16 Create 2 heads containing the same file, once as
@@ -1,4 +1,5 b''
1 1 $ cat <<EOF > merge
2 > from __future__ import print_function
2 3 > import sys, os
3 4 >
4 5 > try:
@@ -8,7 +9,7 b''
8 9 > except ImportError:
9 10 > pass
10 11 >
11 > print "merging for", os.path.basename(sys.argv[1])
12 > print("merging for", os.path.basename(sys.argv[1]))
12 13 > EOF
13 14 $ HGMERGE="$PYTHON ../merge"; export HGMERGE
14 15
@@ -1,6 +1,6 b''
1 1 $ cat <<EOF > merge
2 2 > import sys, os
3 > print "merging for", os.path.basename(sys.argv[1])
3 > print("merging for", os.path.basename(sys.argv[1]))
4 4 > EOF
5 5 $ HGMERGE="$PYTHON ../merge"; export HGMERGE
6 6
@@ -33,7 +33,7 b' Test interactions between mq and patch.e'
33 33 > for line in file(sys.argv[1], 'rb'):
34 34 > line = line.replace('\r', '<CR>')
35 35 > line = line.replace('\n', '<LF>')
36 > print line
36 > print(line)
37 37 > EOF
38 38
39 39 $ hg init repo
@@ -39,7 +39,7 b' commit'
39 39 push
40 40
41 41 $ hg --traceback --cwd b push ../a 2>&1 |
42 > $PYTHON -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
42 > $PYTHON -c 'from __future__ import print_function ; import sys,re; print(re.sub("\n\t", " ", sys.stdin.read()), end="")'
43 43 pushing to ../a
44 44 searching for changes
45 45 adding changesets
@@ -92,7 +92,7 b' unbundle with unrelated source'
92 92 unbundle with correct source
93 93
94 94 $ hg --config notify.sources=unbundle --cwd a unbundle ../test.hg 2>&1 |
95 > $PYTHON -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
95 > $PYTHON -c 'from __future__ import print_function ; import sys,re; print(re.sub("\n\t", " ", sys.stdin.read()), end="")'
96 96 adding changesets
97 97 adding manifests
98 98 adding file changes
@@ -167,7 +167,7 b' merge as a different user'
167 167 push
168 168
169 169 $ hg --traceback --cwd b --config notify.fromauthor=True push ../a 2>&1 |
170 > $PYTHON -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),'
170 > $PYTHON -c 'from __future__ import print_function ; import sys,re; print(re.sub("\n\t", " ", sys.stdin.read()), end="")'
171 171 pushing to ../a
172 172 searching for changes
173 173 adding changesets
General Comments 0
You need to be logged in to leave comments. Login now