diff options
Diffstat (limited to 'coverage')
-rw-r--r-- | coverage/cmdline.py | 6 | ||||
-rw-r--r-- | coverage/control.py | 12 | ||||
-rw-r--r-- | coverage/debug.py | 10 |
3 files changed, 20 insertions, 8 deletions
diff --git a/coverage/cmdline.py b/coverage/cmdline.py index f0160845..3b624724 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -9,7 +9,7 @@ import traceback from coverage import env from coverage.execfile import run_python_file, run_python_module from coverage.misc import CoverageException, ExceptionDuringRun, NoSource -from coverage.debug import info_formatter +from coverage.debug import info_formatter, info_header class Opts(object): @@ -571,12 +571,12 @@ class CoverageScript(object): for info in args: if info == 'sys': sysinfo = self.coverage.sysinfo() - print("-- sys ----------------------------------------") + print(info_header("sys")) for line in info_formatter(sysinfo): print(" %s" % line) elif info == 'data': self.coverage.load() - print("-- data ---------------------------------------") + print(info_header("data")) print("path: %s" % self.coverage.data.filename) print("has_arcs: %r" % self.coverage.data.has_arcs()) summary = self.coverage.data.summary(fullpath=True) diff --git a/coverage/control.py b/coverage/control.py index 36687fe5..8ae96fcf 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -293,14 +293,18 @@ class Coverage(object): self.omit_match = FnmatchMatcher(self.omit) # The user may want to debug things, show info if desired. + wrote_any = False if self.debug.should('config'): - self.debug.write("Configuration values:") config_info = sorted(self.config.__dict__.items()) - self.debug.write_formatted_info(config_info) + self.debug.write_formatted_info("config", config_info) + wrote_any = True if self.debug.should('sys'): - self.debug.write("Debugging info:") - self.debug.write_formatted_info(self.sysinfo()) + self.debug.write_formatted_info("sys", self.sysinfo()) + wrote_any = True + + if wrote_any: + self.debug.write_formatted_info("end", ()) def _canonical_dir(self, morf): """Return the canonical directory of the module or file `morf`.""" diff --git a/coverage/debug.py b/coverage/debug.py index c441dffd..74315231 100644 --- a/coverage/debug.py +++ b/coverage/debug.py @@ -28,12 +28,18 @@ class DebugControl(object): self.output.write(msg+"\n") self.output.flush() - def write_formatted_info(self, info): + def write_formatted_info(self, header, info): """Write a sequence of (label,data) pairs nicely.""" + self.write(info_header(header)) for line in info_formatter(info): self.write(" %s" % line) +def info_header(label): + """Make a nice header string.""" + return "--{0:-<60s}".format(" "+label+" ") + + def info_formatter(info): """Produce a sequence of formatted lines from info. @@ -42,6 +48,8 @@ def info_formatter(info): """ info = list(info) + if not info: + return label_len = max(len(l) for l, _d in info) for label, data in info: if data == []: |