comparison tests/test-ui-color.py @ 43076:2372284d9457

formatting: blacken the codebase This is using my patch to black (https://github.com/psf/black/pull/826) so we don't un-wrap collection literals. Done with: hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S # skip-blame mass-reformatting only # no-check-commit reformats foo_bar functions Differential Revision: https://phab.mercurial-scm.org/D6971
author Augie Fackler <augie@google.com>
date Sun, 06 Oct 2019 09:45:02 -0400
parents 32bc3815efae
children 86e4daa2d54c
comparison
equal deleted inserted replaced
43075:57875cf423c9 43076:2372284d9457
3 import os 3 import os
4 from mercurial import ( 4 from mercurial import (
5 dispatch, 5 dispatch,
6 ui as uimod, 6 ui as uimod,
7 ) 7 )
8 from mercurial.utils import ( 8 from mercurial.utils import stringutil
9 stringutil,
10 )
11 9
12 # ensure errors aren't buffered 10 # ensure errors aren't buffered
13 testui = uimod.ui() 11 testui = uimod.ui()
14 testui.pushbuffer() 12 testui.pushbuffer()
15 testui.write((b'buffered\n')) 13 testui.write(b'buffered\n')
16 testui.warn((b'warning\n')) 14 testui.warn(b'warning\n')
17 testui.write_err(b'error\n') 15 testui.write_err(b'error\n')
18 print(stringutil.pprint(testui.popbuffer(), bprefix=True).decode('ascii')) 16 print(stringutil.pprint(testui.popbuffer(), bprefix=True).decode('ascii'))
19 17
20 # test dispatch.dispatch with the same ui object 18 # test dispatch.dispatch with the same ui object
21 hgrc = open(os.environ["HGRCPATH"], 'wb') 19 hgrc = open(os.environ["HGRCPATH"], 'wb')
32 # call some arbitrary command just so we go through 30 # call some arbitrary command just so we go through
33 # color's wrapped _runcommand twice. 31 # color's wrapped _runcommand twice.
34 def runcmd(): 32 def runcmd():
35 dispatch.dispatch(dispatch.request([b'version', b'-q'], ui_)) 33 dispatch.dispatch(dispatch.request([b'version', b'-q'], ui_))
36 34
35
37 runcmd() 36 runcmd()
38 print("colored? %s" % (ui_._colormode is not None)) 37 print("colored? %s" % (ui_._colormode is not None))
39 runcmd() 38 runcmd()
40 print("colored? %s" % (ui_._colormode is not None)) 39 print("colored? %s" % (ui_._colormode is not None))