- skip-blame because just b'' prefixes
Details
Details
- Reviewers
yuja - Group Reviewers
hg-reviewers - Commits
- rHG236596a67a54: py3: add b'' to test-ui-color.py
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
yuja |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
from __future__ import absolute_import, print_function | from __future__ import absolute_import, print_function | ||||
import os | import os | ||||
from mercurial import ( | from mercurial import ( | ||||
dispatch, | dispatch, | ||||
ui as uimod, | ui as uimod, | ||||
) | ) | ||||
# ensure errors aren't buffered | # ensure errors aren't buffered | ||||
testui = uimod.ui() | testui = uimod.ui() | ||||
testui.pushbuffer() | testui.pushbuffer() | ||||
testui.write(('buffered\n')) | testui.write((b'buffered\n')) | ||||
testui.warn(('warning\n')) | testui.warn((b'warning\n')) | ||||
testui.write_err('error\n') | testui.write_err(b'error\n') | ||||
print(repr(testui.popbuffer())) | print(repr(testui.popbuffer())) | ||||
# test dispatch.dispatch with the same ui object | # test dispatch.dispatch with the same ui object | ||||
hgrc = open(os.environ["HGRCPATH"], 'w') | hgrc = open(os.environ["HGRCPATH"], 'w') | ||||
hgrc.write('[extensions]\n') | hgrc.write(b'[extensions]\n') | ||||
hgrc.write('color=\n') | hgrc.write(b'color=\n') | ||||
hgrc.close() | hgrc.close() | ||||
ui_ = uimod.ui.load() | ui_ = uimod.ui.load() | ||||
ui_.setconfig('ui', 'formatted', 'True') | ui_.setconfig(b'ui', b'formatted', b'True') | ||||
# we're not interested in the output, so write that to devnull | # we're not interested in the output, so write that to devnull | ||||
ui_.fout = open(os.devnull, 'w') | ui_.fout = open(os.devnull, 'w') | ||||
# call some arbitrary command just so we go through | # call some arbitrary command just so we go through | ||||
# color's wrapped _runcommand twice. | # color's wrapped _runcommand twice. | ||||
def runcmd(): | def runcmd(): | ||||
dispatch.dispatch(dispatch.request(['version', '-q'], ui_)) | dispatch.dispatch(dispatch.request([b'version', b'-q'], ui_)) | ||||
runcmd() | runcmd() | ||||
print("colored? %s" % (ui_._colormode is not None)) | print("colored? %s" % (ui_._colormode is not None)) | ||||
runcmd() | runcmd() | ||||
print("colored? %s" % (ui_._colormode is not None)) | print("colored? %s" % (ui_._colormode is not None)) | ||||