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))
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)
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)