summaryrefslogtreecommitdiff
path: root/tests/test-ui-color.py
diff options
context:
space:
mode:
authorLorry <lorry@roadtrain.codethink.co.uk>2012-08-22 14:49:51 +0100
committerLorry <lorry@roadtrain.codethink.co.uk>2012-08-22 14:49:51 +0100
commita498da43c7fdb9f24b73680c02a4a3588cc62d9a (patch)
treedaf8119dae1749b5165b68033a1b23a7375ce9ce /tests/test-ui-color.py
downloadmercurial-tarball-a498da43c7fdb9f24b73680c02a4a3588cc62d9a.tar.gz
Tarball conversion
Diffstat (limited to 'tests/test-ui-color.py')
-rw-r--r--tests/test-ui-color.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/test-ui-color.py b/tests/test-ui-color.py
new file mode 100644
index 0000000..e20bcbc
--- /dev/null
+++ b/tests/test-ui-color.py
@@ -0,0 +1,33 @@
+import os, sys
+from hgext import color
+from mercurial import dispatch, ui
+
+# ensure errors aren't buffered
+testui = color.colorui()
+testui.pushbuffer()
+testui.write('buffered\n')
+testui.warn('warning\n')
+testui.write_err('error\n')
+print repr(testui.popbuffer())
+
+# test dispatch.dispatch with the same ui object
+hgrc = open(os.environ["HGRCPATH"], 'w')
+hgrc.write('[extensions]\n')
+hgrc.write('color=\n')
+hgrc.close()
+
+ui_ = ui.ui()
+ui_.setconfig('ui', 'formatted', 'True')
+
+# we're not interested in the output, so write that to devnull
+ui_.fout = open(os.devnull, 'w')
+
+# call some arbitrary command just so we go through
+# color's wrapped _runcommand twice.
+def runcmd():
+ dispatch.dispatch(dispatch.request(['version', '-q'], ui_))
+
+runcmd()
+print "colored? " + str(issubclass(ui_.__class__, color.colorui))
+runcmd()
+print "colored? " + str(issubclass(ui_.__class__, color.colorui))