def do_debug(self, args): """Implementation of 'coverage debug'.""" if not args: self.help_fn("What information would you like: data, sys?") return ERR for info in args: if info == 'sys': print("-- sys ----------------------------------------") for line in info_formatter(self.coverage.sysinfo()): print(" %s" % line) elif info == 'data': print("-- data ---------------------------------------") self.coverage.load() print("path: %s" % self.coverage.data.filename) print("has_arcs: %r" % self.coverage.data.has_arcs()) summary = self.coverage.data.summary(fullpath=True) if summary: filenames = sorted(summary.keys()) print("\n%d files:" % len(filenames)) for f in filenames: print("%s: %d lines" % (f, summary[f])) else: print("No data collected") else: self.help_fn("Don't know what you mean by %r" % info) return ERR return OK
def do_debug(self, args): if not args: self.help_fn('What information would you like: data, sys?') return ERR for info in args: if info == 'sys': print '-- sys ----------------------------------------' for line in info_formatter(self.coverage.sysinfo()): print ' %s' % line elif info == 'data': print '-- data ---------------------------------------' self.coverage.load() print 'path: %s' % self.coverage.data.filename print 'has_arcs: %r' % self.coverage.data.has_arcs() summary = self.coverage.data.summary(fullpath=True) if summary: filenames = sorted(summary.keys()) print '\n%d files:' % len(filenames) for f in filenames: print '%s: %d lines' % (f, summary[f]) else: print 'No data collected' else: self.help_fn("Don't know what you mean by %r" % info) return ERR return OK
def do_debug(self, args): """Implementation of 'coverage debug'.""" if not args: self.help_fn("What information would you like: data, sys?") return ERR for info in args: if info == 'sys': sys_info = self.coverage.sys_info() print(info_header("sys")) for line in info_formatter(sys_info): print(" %s" % line) elif info == 'data': self.coverage.load() 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) if summary: plugins = self.coverage.data.plugin_data() filenames = sorted(summary.keys()) print("\n%d files:" % len(filenames)) for f in filenames: line = "%s: %d lines" % (f, summary[f]) plugin = plugins.get(f) if plugin: line += " [%s]" % plugin print(line) else: print("No data collected") else: self.help_fn("Don't know what you mean by %r" % info) return ERR return OK
def test_info_formatter_with_generator(self): lines = list(info_formatter(('info%d' % i, i) for i in range(3))) expected = [ ' info0: 0', ' info1: 1', ' info2: 2', ] assert expected == lines
def do_debug(self, args): """Implementation of 'coverage debug'.""" if not args: show_help( "What information would you like: config, data, sys, premain?") return ERR for info in args: if info == 'sys': sys_info = self.coverage.sys_info() print(info_header("sys")) for line in info_formatter(sys_info): print(" %s" % line) elif info == 'data': self.coverage.load() data = self.coverage.get_data() print(info_header("data")) print("path: %s" % self.coverage.get_data().data_filename()) if data: print("has_arcs: %r" % data.has_arcs()) summary = line_counts(data, fullpath=True) filenames = sorted(summary.keys()) print("\n%d files:" % len(filenames)) for f in filenames: line = "%s: %d lines" % (f, summary[f]) plugin = data.file_tracer(f) if plugin: line += " [%s]" % plugin print(line) else: print("No data collected") elif info == 'config': print(info_header("config")) config_info = self.coverage.config.__dict__.items() for line in info_formatter(config_info): print(" %s" % line) elif info == "premain": print(info_header("premain")) from coverage.debug import short_stack print(short_stack()) else: show_help("Don't know what you mean by %r" % info) return ERR return OK
def do_debug(self, args): """Implementation of 'coverage debug'.""" if not args: show_help( "What information would you like: config, data, sys, premain?") return ERR for info in args: if info == 'sys': sys_info = self.coverage.sys_info() print(info_header("sys")) for line in info_formatter(sys_info): print(f" {line}") elif info == 'data': self.coverage.load() data = self.coverage.get_data() print(info_header("data")) print(f"path: {data.data_filename()}") if data: print(f"has_arcs: {data.has_arcs()!r}") summary = line_counts(data, fullpath=True) filenames = human_sorted(summary.keys()) print(f"\n{len(filenames)} files:") for f in filenames: line = f"{f}: {summary[f]} lines" plugin = data.file_tracer(f) if plugin: line += f" [{plugin}]" print(line) else: print("No data collected") elif info == 'config': print(info_header("config")) config_info = self.coverage.config.__dict__.items() for line in info_formatter(config_info): print(f" {line}") elif info == "premain": print(info_header("premain")) print(short_stack()) else: show_help(f"Don't know what you mean by {info!r}") return ERR return OK
def do_debug(self, args): """Implementation of 'coverage debug'.""" if not args: self.help_fn("What information would you like: config, data, sys?") return ERR for info in args: if info == 'sys': sys_info = self.coverage.sys_info() print(info_header("sys")) for line in info_formatter(sys_info): print(" %s" % line) elif info == 'data': self.coverage.load() data = self.coverage.data print(info_header("data")) print("path: %s" % self.coverage.data_files.filename) if data: print("has_arcs: %r" % data.has_arcs()) summary = data.line_counts(fullpath=True) filenames = sorted(summary.keys()) print("\n%d files:" % len(filenames)) for f in filenames: line = "%s: %d lines" % (f, summary[f]) plugin = data.file_tracer(f) if plugin: line += " [%s]" % plugin print(line) else: print("No data collected") elif info == 'config': print(info_header("config")) config_info = self.coverage.config.__dict__.items() for line in info_formatter(config_info): print(" %s" % line) else: self.help_fn("Don't know what you mean by %r" % info) return ERR return OK
def test_info_formatter(self): lines = list(info_formatter([ ('x', 'hello there'), ('very long label', ['one element']), ('regular', ['abc', 'def', 'ghi', 'jkl']), ('nothing', []), ])) self.assertEqual(lines, [ ' x: hello there', 'very long label: one element', ' regular: abc', ' def', ' ghi', ' jkl', ' nothing: -none-', ])
def test_info_formatter(self): lines = list( info_formatter( [ ("x", "hello there"), ("very long label", ["one element"]), ("regular", ["abc", "def", "ghi", "jkl"]), ("nothing", []), ] ) ) self.assertEqual( lines, [ " x: hello there", "very long label: one element", " regular: abc", " def", " ghi", " jkl", " nothing: -none-", ], )
def test_info_formatter_with_generator(self): lines = list(info_formatter(('info%d' % i, i) for i in range(3))) self.assertEqual(lines, ['info0: 0', 'info1: 1', 'info2: 2'])
def test_too_long_label(self): with pytest.raises(AssertionError): list(info_formatter([('this label is way too long and will not fit', 23)]))
def test_info_formatter_with_generator(self): lines = list(info_formatter(("info%d" % i, i) for i in range(3))) self.assertEqual(lines, ["info0: 0", "info1: 1", "info2: 2"])