Mercurial > hg
comparison tests/test-bugzilla.t @ 41343:7370f302be71
py3: port test-bugzilla.t to Python 3
Some assorted fixes required in the extension itself, all around
bytes/str issues.
Differential Revision: https://phab.mercurial-scm.org/D5680
author | Augie Fackler <augie@google.com> |
---|---|
date | Thu, 24 Jan 2019 13:54:45 -0500 |
parents | fc3cca406b2e |
children | 42d2b31cee0b |
comparison
equal
deleted
inserted
replaced
41342:fe83040400b7 | 41343:7370f302be71 |
---|---|
1 mock bugzilla driver for testing template output: | 1 mock bugzilla driver for testing template output: |
2 | 2 |
3 $ cat <<EOF > bzmock.py | 3 $ cat <<EOF > bzmock.py |
4 > from __future__ import absolute_import | 4 > from __future__ import absolute_import |
5 > from mercurial import extensions | 5 > from mercurial import extensions |
6 > from mercurial import pycompat | |
6 > from mercurial import registrar | 7 > from mercurial import registrar |
8 > from mercurial.utils import stringutil | |
7 > | 9 > |
8 > configtable = {} | 10 > configtable = {} |
9 > configitem = registrar.configitem(configtable) | 11 > configitem = registrar.configitem(configtable) |
10 > | 12 > |
11 > configitem(b'bugzilla', b'mocklog', | 13 > configitem(b'bugzilla', b'mocklog', |
16 > class bzmock(bugzilla.bzaccess): | 18 > class bzmock(bugzilla.bzaccess): |
17 > def __init__(self, ui): | 19 > def __init__(self, ui): |
18 > super(bzmock, self).__init__(ui) | 20 > super(bzmock, self).__init__(ui) |
19 > self._logfile = ui.config(b'bugzilla', b'mocklog') | 21 > self._logfile = ui.config(b'bugzilla', b'mocklog') |
20 > def updatebug(self, bugid, newstate, text, committer): | 22 > def updatebug(self, bugid, newstate, text, committer): |
21 > with open(self._logfile, 'a') as f: | 23 > with open(pycompat.fsdecode(self._logfile), 'ab') as f: |
22 > f.write('update bugid=%r, newstate=%r, committer=%r\n' | 24 > f.write(b'update bugid=%s, newstate=%s, committer=%s\n' |
23 > % (bugid, newstate, committer)) | 25 > % (stringutil.pprint(bugid), |
24 > f.write('----\n' + text + '\n----\n') | 26 > stringutil.pprint(newstate), |
27 > stringutil.pprint(committer))) | |
28 > f.write(b'----\n' + text + b'\n----\n') | |
25 > def notify(self, bugs, committer): | 29 > def notify(self, bugs, committer): |
26 > with open(self._logfile, 'a') as f: | 30 > with open(pycompat.fsdecode(self._logfile), 'ab') as f: |
27 > f.write('notify bugs=%r, committer=%r\n' | 31 > f.write(b'notify bugs=%s, committer=%s\n' |
28 > % (bugs, committer)) | 32 > % (stringutil.pprint(bugs), |
33 > stringutil.pprint(committer))) | |
29 > bugzilla.bugzilla._versions[b'mock'] = bzmock | 34 > bugzilla.bugzilla._versions[b'mock'] = bzmock |
30 > EOF | 35 > EOF |
31 | 36 |
32 set up mock repository: | 37 set up mock repository: |
33 | 38 |