예제 #1
0
 def test_py2_bytes_not_mangled(self):
     from clint.textui.colored import ColoredString
     # On python 2 make sure the same bytes come out as went in
     new_str = ColoredString('RED', '\xe4')
     assert '\xe4' in str(new_str)
     from clint.textui import puts
     puts(new_str)
예제 #2
0
        def format(self, record):
            msg = record.getMessage()

            out_msg = '{}:{}:{}'.format(str(record.levelname), record.name,
                                        str(msg))

            if hasattr(record.msg, 'color'):
                color = record.msg.color

                colored_msg = str(ColoredString(color, str(out_msg)))
                return colored_msg

            return out_msg
예제 #3
0
 def test_clint_force_color_env_var(self):
     from clint.textui.colored import ColoredString
     os.environ['CLINT_FORCE_COLOR'] = "1"
     new_str = ColoredString('RED', 'hello world')
     assert new_str.always_color == True
예제 #4
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"
예제 #5
0
 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)
예제 #6
0
 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"
예제 #7
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"
예제 #8
0
 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)
예제 #9
0
 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"
예제 #10
0
 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
예제 #11
0
 def test_replace(self):
     new_str = ColoredString('green', "hello world")
     output = new_str.replace("world", "universe")
     assert output.s == "hello universe"
예제 #12
0
 def test_find(self):
     new_str = ColoredString('blue', "hello world")
     output = new_str.find('h')
     self.assertEqual(output, 0)
예제 #13
0
 def test_split(self):
     new_str = ColoredString('red', "hello world")
     output = new_str.split()
     assert output[0].s == "hello"
예제 #14
0
파일: sync_command.py 프로젝트: troylar/S4
 def _colored(self, color, text):
     return text if self.args.no_colors else ColoredString(color, text)