diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2022-02-04 20:05:05 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2022-02-06 11:09:53 -0500 |
commit | 642647abdadea247c32d8dad8e5755f52238574c (patch) | |
tree | c20650a43f3cbf4d8ef83ac52855861e748a2cc4 /coverage/debug.py | |
parent | bf99bb663940f203bee6d373f6b6f30840831fab (diff) | |
download | python-coveragepy-git-642647abdadea247c32d8dad8e5755f52238574c.tar.gz |
debug: add 'pybehave' debug information
It shows the behavior flags from coverage.env.
Diffstat (limited to 'coverage/debug.py')
-rw-r--r-- | coverage/debug.py | 13 |
1 files changed, 11 insertions, 2 deletions
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) |