summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2014-11-11 10:03:41 +0100
committerGeorg Brandl <georg@python.org>2014-11-11 10:03:41 +0100
commit958498ae786cb99087fc0a9a085c8fc4aca9918c (patch)
treed4e0a1f2c30e7ce7464f832be25c05d497952b8d
parente274c81a7e953c2988db97fb7dca3896c0e80bea (diff)
downloadpygments-958498ae786cb99087fc0a9a085c8fc4aca9918c.tar.gz
More test coverage for pygments.console
-rw-r--r--tests/test_util.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/tests/test_util.py b/tests/test_util.py
index e480b503..d6ebd51d 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -10,7 +10,7 @@
import re
import unittest
-from pygments import util
+from pygments import util, console
class FakeLexer(object):
@@ -40,7 +40,6 @@ class UtilTest(unittest.TestCase):
equals(util.get_list_opt({}, 'a', '1 2'), ['1', '2'])
raises(util.OptionError, util.get_list_opt, {}, 'a', 1)
-
def test_docstring_headline(self):
def f1():
"""
@@ -157,3 +156,20 @@ class UtilTest(unittest.TestCase):
# keeps first
x = util.duplicates_removed(('a', 'b', 'a'))
self.assertEqual(['a', 'b'], x)
+
+
+class ConsoleTest(unittest.TestCase):
+
+ def test_ansiformat(self):
+ f = console.ansiformat
+ c = console.codes
+ all_attrs = f('+*_blue_*+', 'text')
+ self.assertTrue(c['blue'] in all_attrs and c['blink'] in all_attrs
+ and c['bold'] in all_attrs and c['underline'] in all_attrs
+ and c['reset'] in all_attrs)
+ self.assertRaises(KeyError, f, '*mauve*', 'text')
+
+ def test_functions(self):
+ self.assertEqual(console.reset_color(), console.codes['reset'])
+ self.assertEqual(console.colorize('blue', 'text'),
+ console.codes['blue'] + 'text' + console.codes['reset'])