summaryrefslogtreecommitdiff
path: root/coverage
diff options
context:
space:
mode:
Diffstat (limited to 'coverage')
-rw-r--r--coverage/control.py13
-rw-r--r--coverage/debug.py13
2 files changed, 24 insertions, 2 deletions
diff --git a/coverage/control.py b/coverage/control.py
index 9dfa59fb..a3fda8d8 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -329,6 +329,19 @@ class Coverage:
write_formatted_info(self._debug, header, info)
wrote_any = True
+ if self._debug.should('pybehave'):
+ info = [
+ (name, value) for name, value in env.__dict__.items()
+ if not name.startswith("_") and
+ name != "PYBEHAVIOR" and
+ not isinstance(value, type(os))
+ ] + [
+ (name, value) for name, value in env.PYBEHAVIOR.__dict__.items()
+ if not name.startswith("_")
+ ]
+ write_formatted_info(self._debug, "pybehave", sorted(info))
+ wrote_any = True
+
if wrote_any:
write_formatted_info(self._debug, "end", ())
diff --git a/coverage/debug.py b/coverage/debug.py
index 74b59d0e..e6f93aa6 100644
--- a/coverage/debug.py
+++ b/coverage/debug.py
@@ -118,7 +118,10 @@ def info_formatter(info):
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)
@@ -128,7 +131,13 @@ def info_formatter(info):
def write_formatted_info(writer, header, info):
- """Write a sequence of (label,data) pairs nicely."""
+ """Write a sequence of (label,data) pairs nicely.
+
+ `writer` has a .write(str) method. `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.
+
+ """
writer.write(info_header(header))
for line in info_formatter(info):
writer.write(" %s" % line)