Beispiel #1
0
 def test_join(self):
     assert Str.red(',').join(['1', '2', '3',
                               '4']) == ','.join(['1', '2', '3', '4'])
     assert Str.red('!!!').join(['1', '2', '3',
                                 '4']) == '!!!'.join(['1', '2', '3', '4'])
     assert Str.red(',').join(['1', Str.blue('2'), '3',
                               '4']) == ','.join(['1', '2', '3', '4'])
     assert Str.red(',').join([
         '1', Str.blue('2'), '3', '4'
     ]) != Str.red(',').join(['1', Str.red('2'), '3', '4'])
     assert Str.red(',').join([
         '1', Str.blue('2'), '3', '4'
     ]) != Str.red(',').join(['1', '2', Str.red('3'), '4'])
Beispiel #2
0
 def test_replace(self):
     assert self.obj.replace('o', 'XX') == self.raw.replace('o', 'XX')
     assert self.obj.replace(Str.blue('A'),
                             'XX') == self.raw.replace('A', 'XX')
     assert self.obj.replace(Str.red('o'), 'XX') != self.raw.replace(
         'o', 'XX')
     assert self.obj.replace('o', Str.red('x')) == self.obj.replace(
         'o', Str.red('x'))
     assert self.obj.replace('o', Str.red('x')) != self.obj.replace(
         'o', Str.blue('x'))
     assert self.obj.replace(Str.red('x'), 'o') != self.obj.replace(
         Str.red('x'), Str.blue('o'))
     assert self.obj.replace(Str.red('x'), 'o') == self.obj.replace(
         Str.red('x'), Str('o'))
     assert self.obj.replace(Str.green('o'), 'x') != self.obj.replace(
         'o', 'x', 2)
     assert self.obj.replace(Str.green('o'),
                             'x') == self.obj.replace('o', 'x', 3)
Beispiel #3
0
 def test_rpartition(self):
     assert self.obj.rpartition('x') == self.raw.rpartition('x')
     assert self.obj.rpartition(Str.red('x')) == (self.obj[:-1],
                                                  self.obj[-1], '')
     assert self.obj.rpartition(Str.red('x')) != self.obj.rpartition(
         Str.green('x'))
     assert self.obj.rpartition(Str.green('o')) == (self.obj[:8],
                                                    self.obj[8:-2],
                                                    self.obj[-2:])
     assert self.obj.rpartition(Str.blue('x')) == ('', '', self.obj[:])
Beispiel #4
0
 def test_partition(self):
     assert self.obj.partition('x') == self.raw.partition('x')
     assert self.obj.partition(Str.red('x')) == ('', self.obj[:1],
                                                 self.obj[1:])
     assert self.obj.partition(Str.red('x')) != self.obj.partition(
         Str.green('x'))
     assert self.obj.partition(Str.green('o')) == (self.obj[:2],
                                                   self.obj[2:3],
                                                   self.obj[3:])
     assert self.obj.partition(Str.blue('x')) == (self.obj[:], '', '')
Beispiel #5
0
 def test_center(self):
     assert self.obj.center(10) == self.obj
     assert self.obj.center(30, '*') == self.raw.center(30, "*")
     assert self.obj.center(30, Str.blue('*')) == self.raw.center(30, "*")
     assert self.obj.center(30, Str.blue('*')) != self.obj.center(30, Str.red('*'))
Beispiel #6
0
 def test_rjust(self):
     assert self.obj.rjust(10) == self.obj
     assert self.obj.rjust(30, '*') == self.raw.rjust(30, '*')
     assert self.obj.rjust(30, Str.blue('*')) == self.raw.rjust(30, '*')
     assert self.obj.rjust(30, Str.blue('*')) != self.obj.rjust(30, Str.red('*'))
Beispiel #7
0
     [__  |__| |___ |___ |\ |      
     ___] |  | |___ |___ | \|      
                                   
Sheen Has been installed successful 
""")

for i in range(len(text)):
    if text[i] != '\n':
        text[i:i + 1] = Color.RGB(
            i + 16) if text[i] == ' ' else Color.rgb(231) | Color.RGB(i + 16)

text += Str("""
>>> from sheen import Str, Color
>>> Str.blue('render font color with lowercase')
""")
text += repr(Str.blue('render font color with lowercase'))
text += Str('''\n>>> Str.BLUE('render background color with uppercase')\n''')
text += repr(Str.BLUE('render background color with uppercase'))
text += Str('''\n>>> Str.Underline('render style with capital')\n''')
text += repr(Str.Underline('render style with capital'))
text += Str('''\n>>> Str.lightblue.BLUE('joint rendering with dot')\n''')
text += repr(Str.lightblue.BLUE('joint rendering with dot'))
text += Str(
    '''\n>>> Str.BLUE.lightblue("yes! it's free, no order restrain")\n''')
text += repr(Str.BLUE.lightblue("yes! it's free, no order restrain"))
text += Str(
    '''\n>>> Str.cyan.LIGHTCYAN.Underline('esay to lean, ease to use')\n''')
text += repr(Str.cyan.LIGHTCYAN.Underline('esay to lean, ease to use'))
text += Str(
    '''\n>>> Str.lightcyan("You can use it like builtin 'str'").split(' ')\n'''
)