Exemplo n.º 1
0
def test_pretty_dict(colorpatch):
    x = {1: 2, "foo": "bar", "baz": True}
    assert x == eval(color.pretty_dict(x))
    x = {"foo": [1, 2], "bar": ["a", "b", "c"]}
    assert x == eval(color.pretty_dict(x))
    x = {"yes": {"maybe": 1, "no": 2}, "no": {1: 2, 4: True}}
    assert x == eval(color.pretty_dict(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)