summaryrefslogtreecommitdiff
path: root/blessings/tests.py
diff options
context:
space:
mode:
authorErik Rose <erik@mozilla.com>2011-11-16 14:27:33 -0800
committerErik Rose <erik@mozilla.com>2011-11-16 16:17:48 -0800
commit82c4be7bac1c773c9f168c57e5878ebd125cadb8 (patch)
tree70b3f0594a0ad304a0a7f8ac1fe5601d6da4d668 /blessings/tests.py
parent571e8afc6550b5547e41808d726d96b74c4c8893 (diff)
downloadblessings-82c4be7bac1c773c9f168c57e5878ebd125cadb8.tar.gz
Add a helpful exception.
Diffstat (limited to 'blessings/tests.py')
-rw-r--r--blessings/tests.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/blessings/tests.py b/blessings/tests.py
index ec7e640..8d7508a 100644
--- a/blessings/tests.py
+++ b/blessings/tests.py
@@ -117,6 +117,25 @@ def test_formatting_functions_without_tty():
"""Test crazy-ass formatting wrappers when there's no tty."""
t = Terminal(stream=StringIO())
eq_(t.green('hi'), 'hi')
- eq_(t.bold_green('boö'), 'boö') # unicode
+ eq_(t.bold_green(u'boö'), u'boö') # unicode
eq_(t.bold_underline_green_on_red('boo'), 'boo')
eq_(t.on_bright_red_bold_bright_green_underline('meh'), 'meh')
+
+
+def test_nice_formatting_errors():
+ """Make sure you get nice hints if you misspell a formatting wrapper."""
+ t = Terminal()
+ try:
+ t.bold_misspelled('hey')
+ except TypeError, e:
+ assert 'probably misspelled' in e[0]
+
+ try:
+ t.bold_misspelled(None) # an arbitrary non-string
+ except TypeError, e:
+ assert 'probably misspelled' not in e[0]
+
+ try:
+ t.bold_misspelled('a', 'b') # >1 string arg
+ except TypeError, e:
+ assert 'probably misspelled' not in e[0]