eric7/DebugClients/Python/coverage/debug.py

branch
eric7
changeset 8991
2fc945191992
parent 8775
0802ae193343
child 9099
0e511e0e94a3
--- a/eric7/DebugClients/Python/coverage/debug.py	Sun Mar 20 17:26:35 2022 +0100
+++ b/eric7/DebugClients/Python/coverage/debug.py	Sun Mar 20 17:49:44 2022 +0100
@@ -118,7 +118,10 @@
     for label, data in info:
         if data == []:
             data = "-none-"
-        if isinstance(data, (list, set, tuple)):
+        if isinstance(data, tuple) and len(repr(tuple(data))) < 30:
+            # Convert to tuple to scrub namedtuples.
+            yield "%*s: %r" % (label_len, label, tuple(data))
+        elif isinstance(data, (list, set, tuple)):
             prefix = "%*s:" % (label_len, label)
             for e in data:
                 yield "%*s %s" % (label_len+1, prefix, e)
@@ -127,11 +130,18 @@
             yield "%*s: %s" % (label_len, label, data)
 
 
-def write_formatted_info(writer, header, info):
-    """Write a sequence of (label,data) pairs nicely."""
-    writer.write(info_header(header))
+def write_formatted_info(write, header, info):
+    """Write a sequence of (label,data) pairs nicely.
+
+    `write` is a function write(str) that accepts each line of output.
+    `header` is a string to start the section.  `info` is a sequence of
+    (label, data) pairs, where label is a str, and data can be a single
+    value, or a list/set/tuple.
+
+    """
+    write(info_header(header))
     for line in info_formatter(info):
-        writer.write(" %s" % line)
+        write(f" {line}")
 
 
 def short_stack(limit=None, skip=0):

eric ide

mercurial