mirror of
https://github.com/kennethreitz/clint.git
synced 2026-06-05 14:50:17 +00:00
b69ceb18d2
All str methods work for ColoredStrings with expected functionality, excepting .join(). Retained some other method definitions in order to retain expected functionality. Added tests for ColoredString.
47 lines
1.1 KiB
Python
Executable File
47 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""Clint Test Suite."""
|
|
|
|
import unittest
|
|
|
|
|
|
class TablibTestCase(unittest.TestCase):
|
|
"""Tablib test cases."""
|
|
|
|
def setUp(self):
|
|
import clint
|
|
|
|
|
|
def tearDown(self):
|
|
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")
|
|
output = new_str.replace("world", "universe")
|
|
assert output.s == "hello universe"
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|