##// END OF EJS Templates
py3: fix module imports in tests, as flagged by test-check-module-imports.t...
Matt Harbison -
r40405:ef6cab79 default
parent child Browse files
Show More
@@ -61,8 +61,8 b' This command is ancient:'
61 61 Verify that updating to revision 0 via commands.update() works properly
62 62
63 63 $ cat <<EOF > update_to_rev0.py
64 > from mercurial import ui, hg, commands
65 > myui = ui.ui.load()
64 > from mercurial import commands, hg, ui as uimod
65 > myui = uimod.ui.load()
66 66 > repo = hg.repository(myui, path=b'.')
67 67 > commands.update(myui, repo, rev=b"0")
68 68 > EOF
@@ -351,7 +351,8 b' when using chg, blackbox.log should get '
351 351 $ chg noop
352 352
353 353 $ cat > showsize.py << 'EOF'
354 > import os, sys
354 > import os
355 > import sys
355 356 > limit = 500
356 357 > for p in sys.argv[1:]:
357 358 > size = os.stat(p).st_size
@@ -934,7 +934,7 b' Test lazily acquiring the lock during un'
934 934
935 935 $ cat >> $TESTTMP/locktester.py <<EOF
936 936 > import os
937 > from mercurial import extensions, bundle2, error
937 > from mercurial import bundle2, error, extensions
938 938 > def checklock(orig, repo, *args, **kwargs):
939 939 > if repo.svfs.lexists(b"lock"):
940 940 > raise error.Abort(b"Lock should not be taken")
@@ -558,8 +558,8 b' Issue2267: Error in 1.6 hg.py: TypeError'
558 558 iterable in addbranchrevs()
559 559
560 560 $ cat <<EOF > simpleclone.py
561 > from mercurial import ui, hg
562 > myui = ui.ui.load()
561 > from mercurial import hg, ui as uimod
562 > myui = uimod.ui.load()
563 563 > repo = hg.repository(myui, b'a')
564 564 > hg.clone(myui, {}, repo, dest=b"ua")
565 565 > EOF
@@ -571,8 +571,8 b' iterable in addbranchrevs()'
571 571 $ rm -r ua
572 572
573 573 $ cat <<EOF > branchclone.py
574 > from mercurial import ui, hg, extensions
575 > myui = ui.ui.load()
574 > from mercurial import extensions, hg, ui as uimod
575 > myui = uimod.ui.load()
576 576 > extensions.loadall(myui)
577 577 > repo = hg.repository(myui, b'a')
578 578 > hg.clone(myui, {}, repo, dest=b"ua", branch=[b"stable",])
@@ -80,8 +80,8 b' transplant bug fixes onto release branch'
80 80
81 81 now test that we fixed the bug for all scripts/extensions
82 82 $ cat > $TESTTMP/committwice.py <<__EOF__
83 > from mercurial import ui, hg, match, node
84 > from time import sleep
83 > import time
84 > from mercurial import hg, match, node, ui as uimod
85 85 >
86 86 > def replacebyte(fn, b):
87 87 > f = open(fn, "rb+")
@@ -94,12 +94,12 b' now test that we fixed the bug for all s'
94 94 > % (rev, b', '.join(b"'%s'" % f
95 95 > for f in repo[rev].files())))
96 96 >
97 > repo = hg.repository(ui.ui.load(), b'.')
97 > repo = hg.repository(uimod.ui.load(), b'.')
98 98 > assert len(repo) == 6, \
99 99 > "initial: len(repo): %d, expected: 6" % len(repo)
100 100 >
101 101 > replacebyte(b"bugfix", b"u")
102 > sleep(2)
102 > time.sleep(2)
103 103 > try:
104 104 > repo.ui.status(b"PRE: len(repo): %d\n" % len(repo))
105 105 > wlock = repo.wlock()
@@ -342,7 +342,7 b' Test warning on config option access and'
342 342 $ cat << EOF > ${TESTTMP}/buggyconfig.py
343 343 > """A small extension that tests our developer warnings for config"""
344 344 >
345 > from mercurial import registrar, configitems
345 > from mercurial import configitems, registrar
346 346 >
347 347 > cmdtable = {}
348 348 > command = registrar.command(cmdtable)
@@ -278,9 +278,10 b' Test roundtrip encoding/decoding of utf8'
278 278
279 279 #if hypothesis
280 280
281 >>> from hypothesishelpers import *
281 >>> import hypothesishelpers
282 282 >>> from mercurial import encoding
283 >>> roundtrips(st.binary(), encoding.fromutf8b, encoding.toutf8b)
283 >>> hypothesishelpers.roundtrips(hypothesishelpers.st.binary(),
284 ... encoding.fromutf8b, encoding.toutf8b)
284 285 Round trip OK
285 286
286 287 #endif
@@ -1266,7 +1266,8 b' Broken disabled extension and command:'
1266 1266 > "broken extension'
1267 1267 > NO_CHECK_EOF
1268 1268 $ cat > path.py <<EOF
1269 > import os, sys
1269 > import os
1270 > import sys
1270 1271 > sys.path.insert(0, os.environ['HGEXTPATH'])
1271 1272 > EOF
1272 1273 $ HGEXTPATH=`pwd`
@@ -285,7 +285,8 b' override commit message'
285 285 $ rm -r b
286 286
287 287 $ cat > mkmsg.py <<EOF
288 > import email.message, sys
288 > import email.message
289 > import sys
289 290 > msg = email.message.Message()
290 291 > patch = open(sys.argv[1], 'rb').read()
291 292 > msg.set_payload(b'email commit message\n' + patch)
@@ -383,7 +384,8 b' subject: duplicate detection, removal of'
383 384 The '---' tests the gitsendmail handling without proper mail headers
384 385
385 386 $ cat > mkmsg2.py <<EOF
386 > import email.message, sys
387 > import email.message
388 > import sys
387 389 > msg = email.message.Message()
388 390 > patch = open(sys.argv[1], 'rb').read()
389 391 > msg.set_payload(b'email patch\n\nnext line\n---\n' + patch)
@@ -1871,8 +1873,8 b' Importing some extra header'
1871 1873 ===========================
1872 1874
1873 1875 $ cat > $TESTTMP/parseextra.py <<EOF
1876 > import mercurial.cmdutil
1874 1877 > import mercurial.patch
1875 > import mercurial.cmdutil
1876 1878 >
1877 1879 > def processfoo(repo, data, extra, opts):
1878 1880 > if b'foo' in data:
@@ -153,7 +153,9 b' not found (this is intentionally using b'
153 153 $ . "$TESTDIR/helpers-testrepo.sh"
154 154
155 155 $ cat >> wixxml.py << EOF
156 > import os, subprocess, sys
156 > import os
157 > import subprocess
158 > import sys
157 159 > import xml.etree.ElementTree as ET
158 160 >
159 161 > # MSYS mangles the path if it expands $TESTDIR
@@ -22,9 +22,9 b''
22 22 o c0
23 23
24 24
25 >>> from mercurial.ui import ui
26 >>> from mercurial.hg import repository
27 >>> repo = repository(ui())
25 >>> from mercurial import hg
26 >>> from mercurial import ui as uimod
27 >>> repo = hg.repository(uimod.ui())
28 28 >>> for anc in repo.changelog.ancestors([4], inclusive=True):
29 29 ... print(anc)
30 30 4
@@ -3,7 +3,7 b' Tests for the journal extension; records'
3 3 $ cat >> testmocks.py << EOF
4 4 > # mock out procutil.getuser() and util.makedate() to supply testable values
5 5 > import os
6 > from mercurial import util, pycompat
6 > from mercurial import pycompat, util
7 7 > from mercurial.utils import dateutil, procutil
8 8 > def mockgetuser():
9 9 > return b'foobar'
@@ -244,7 +244,7 b' pager is globally set to off using a fla'
244 244 Pager should not override the exit code of other commands
245 245
246 246 $ cat >> $TESTTMP/fortytwo.py <<'EOF'
247 > from mercurial import registrar, commands
247 > from mercurial import commands, registrar
248 248 > cmdtable = {}
249 249 > command = registrar.command(cmdtable)
250 250 > @command(b'fortytwo', [], b'fortytwo', norepo=True)
@@ -27,8 +27,7 b' We approximate that by reducing the read'
27 27
28 28 $ cat >> test.py << EOF
29 29 > from __future__ import print_function
30 > from mercurial import changelog, vfs
31 > from mercurial.node import *
30 > from mercurial import changelog, node, vfs
32 31 >
33 32 > class singlebyteread(object):
34 33 > def __init__(self, real):
@@ -59,7 +58,7 b' We approximate that by reducing the read'
59 58 > cl = changelog.changelog(opener('.hg/store'))
60 59 > print(len(cl), 'revisions:')
61 60 > for r in cl:
62 > print(short(cl.node(r)))
61 > print(node.short(cl.node(r)))
63 62 > EOF
64 63 $ "$PYTHON" test.py
65 64 2 revisions:
@@ -41,8 +41,8 b' utility to run the test - start a push i'
41 41 python hook
42 42
43 43 $ cat <<EOF > reject.py
44 > import os, time
45 > from mercurial import ui, localrepo
44 > import os
45 > import time
46 46 > def rejecthook(ui, repo, hooktype, node, **opts):
47 47 > ui.write(b'hook %s\\n' % repo[b'tip'].hex())
48 48 > # create the notify file so caller knows we're running
@@ -66,7 +66,7 b' Install an extension that can sleep and '
66 66
67 67 $ cat >> sleepext.py << EOF
68 68 > import time
69 > from mercurial import registrar, commands
69 > from mercurial import registrar
70 70 > cmdtable = {}
71 71 > command = registrar.command(cmdtable)
72 72 > @command(b'sleep', [], b'hg sleep')
@@ -50,7 +50,8 b' delete an untracked file'
50 50 $ touch untracked_file
51 51 $ touch untracked_file_readonly
52 52 $ "$PYTHON" <<EOF
53 > import os, stat
53 > import os
54 > import stat
54 55 > f= 'untracked_file_readonly'
55 56 > os.chmod(f, stat.S_IMODE(os.stat(f).st_mode) & ~stat.S_IWRITE)
56 57 > EOF
General Comments 0
You need to be logged in to leave comments. Login now