mirror of
https://github.com/kennethreitz/clint.git
synced 2026-06-05 06:46:16 +00:00
Test for unicode error in magic methods (Python 2)
This commit is contained in:
+11
-6
@@ -18,25 +18,25 @@ class ClintTestCase(unittest.TestCase):
|
||||
pass
|
||||
|
||||
class ColoredStringTestCase(unittest.TestCase):
|
||||
|
||||
|
||||
def setUp(self):
|
||||
from clint.textui.colored import ColoredString
|
||||
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
|
||||
def test_split(self):
|
||||
from clint.textui.colored import ColoredString
|
||||
new_str = ColoredString('red', "hello world")
|
||||
output = new_str.split()
|
||||
assert output[0].s == "hello"
|
||||
|
||||
|
||||
def test_find(self):
|
||||
from clint.textui.colored import ColoredString
|
||||
new_str = ColoredString('blue', "hello world")
|
||||
output = new_str.find('h')
|
||||
self.assertEqual(output, 0)
|
||||
|
||||
|
||||
def test_replace(self):
|
||||
from clint.textui.colored import ColoredString
|
||||
new_str = ColoredString('green', "hello world")
|
||||
@@ -49,7 +49,6 @@ class ColoredStringTestCase(unittest.TestCase):
|
||||
new_str = ColoredString('RED', '\xe4')
|
||||
assert '\xe4' in str(new_str)
|
||||
from clint.textui import puts
|
||||
puts(new_str)
|
||||
|
||||
def test_clint_force_color_env_var(self):
|
||||
from clint.textui.colored import ColoredString
|
||||
@@ -57,6 +56,12 @@ class ColoredStringTestCase(unittest.TestCase):
|
||||
new_str = ColoredString('RED', 'hello world')
|
||||
assert new_str.always_color == True
|
||||
|
||||
def test_clint_unicode_radd(self):
|
||||
from clint.textui.colored import ColoredString
|
||||
inp_str = u'hello \u263A'
|
||||
new_str = u'' + ColoredString('RED', inp_str)
|
||||
assert inp_str.encode('utf-8') in new_str
|
||||
|
||||
|
||||
class TextuiFormatterTestCase(unittest.TestCase):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user