Exemplo n.º 1
0
def test_pretty_sequence(colorpatch):
    x = [1, 2, 3, 4, 5]
    assert x == eval(color.pretty_sequence(x))
    x = (1, 2, 3, 4, 5)
    assert x == eval(color.pretty_sequence(x))
    x = [{"foo": "bar"}, {"potato": 123}]
    assert x == eval(color.pretty_sequence(x))
    x = [
        "0000000100000000000000000000000000000000000000000000000000000000",
        "0000000100000000000000000000000000000000000000000000000000000000",
        "0000000100000000000000000000000000000000000000000000000000000000",
    ]
    assert x == eval(color.pretty_sequence(x))
Exemplo n.º 2
0
 def _console_write(self, obj):
     text = repr(obj)
     try:
         if obj and isinstance(obj, dict):
             text = color.pretty_dict(obj)
         elif obj and isinstance(obj, (tuple, list, set)):
             text = color.pretty_sequence(obj)
     except (SyntaxError, NameError):
         pass
     print(text)
Exemplo n.º 3
0
 def _console_write(self, obj):
     text = repr(obj)
     try:
         if obj and isinstance(obj, dict):
             text = color.pretty_dict(obj)
         elif obj and isinstance(obj, (tuple, list, set)):
             text = color.pretty_sequence(obj)
     except (SyntaxError, NameError):
         pass
     if CONFIG.settings["console"]["show_colors"]:
         text = color.highlight(text)
     self.write(text)