changeset 218:b329b4d4d184

Fix regression in line counting in `<python:trace>` command, introduced in [226]. The number of covered lines was mistakenly being used as the total number of lines of code.
author cmlenz
date Wed, 21 Sep 2005 22:46:15 +0000
parents 44e91849ca43
children aef09843d367
files bitten/build/pythontools.py
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/bitten/build/pythontools.py
+++ b/bitten/build/pythontools.py
@@ -137,7 +137,6 @@
                     covered_modules.add(modname)
                     module = xmlio.Element('coverage', name=modname,
                                            file=filename.replace(os.sep, '/'),
-                                           lines=int(match.group(1)),
                                            percentage=int(match.group(2)))
                     coverage_path = ctxt.resolve(coverdir, modname + '.cover')
                     if os.path.exists(coverage_path):
@@ -154,12 +153,19 @@
                                         lines.append('0')
                         finally:
                             coverage_file.close()
+                        module.attr['lines'] = len(lines)
                         module.append(xmlio.Element('line_hits')[
                             ' '.join(lines)
                         ])
                     else:
                         log.warning('No coverage file for module %s at %s',
                                     modname, coverage_path)
+
+                        # Estimate total number of lines from covered lines and
+                        # percentage
+                        lines = int(match.group(1))
+                        percentage = int(match.group(2))
+                        module.attr['lines'] = lines * 100 / percentage
                     coverage.append(module)
 
             for filename in missing_files:
Copyright (C) 2012-2017 Edgewall Software