Mercurial > hg
annotate tests/mockblackbox.py @ 45903:64faa55716f4
tests: make test-worker.t pass on py2
I broke the py2 version in https://phab.mercurial-scm.org/D9287
because the `WorkerError.__bytes__()` (or `.__str__()`?) output was
different in py2 compared to py3. Part of the problem was that I
didn't propagate the status code that was passed in to the superclass
so it could get printed. This patch fixes that. I don't know how it
worked on py3 before this patch...
I also added the usual `__bytes__ = _tobytes` override for good
measure. It doesn't seem to be needed for tests to pass, though.
Differential Revision: https://phab.mercurial-scm.org/D9377
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 23 Nov 2020 11:56:10 -0800 |
parents | 2372284d9457 |
children | 6000f5b25c9b |
rev | line source |
---|---|
28943
417380aa5bbe
py3: use absolute_import in mockblackbox.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28028
diff
changeset
|
1 from __future__ import absolute_import |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37120
diff
changeset
|
2 from mercurial.utils import procutil |
24705
0ead0a07ed9c
tests: move mock blackbox extension into own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
3 |
32412
043948c84647
devel: update blackbox to use default-date
Boris Feld <boris.feld@octobus.net>
parents:
28943
diff
changeset
|
4 # XXX: we should probably offer a devel option to do this in blackbox directly |
24705
0ead0a07ed9c
tests: move mock blackbox extension into own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
5 def getuser(): |
36105
f49c3ee5b02f
py3: use b'' in mockblackbox.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
32412
diff
changeset
|
6 return b'bob' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37120
diff
changeset
|
7 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37120
diff
changeset
|
8 |
28028
ac49ecb2a897
tests: mock getpid to reduce glob usage
timeless <timeless@mozdev.org>
parents:
24705
diff
changeset
|
9 def getpid(): |
ac49ecb2a897
tests: mock getpid to reduce glob usage
timeless <timeless@mozdev.org>
parents:
24705
diff
changeset
|
10 return 5000 |
24705
0ead0a07ed9c
tests: move mock blackbox extension into own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
11 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
37120
diff
changeset
|
12 |
24705
0ead0a07ed9c
tests: move mock blackbox extension into own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
13 # mock the date and user apis so the output is always the same |
0ead0a07ed9c
tests: move mock blackbox extension into own file
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
14 def uisetup(ui): |
37120
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36105
diff
changeset
|
15 procutil.getuser = getuser |
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
36105
diff
changeset
|
16 procutil.getpid = getpid |