diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2010-06-18 08:42:43 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2010-06-18 08:42:43 -0400 |
commit | fb02cb27f17c619cf51acfc4c3c1f45817208523 (patch) | |
tree | 308dc26918a8f260144c94698f0804b5c9e3ec11 /coverage/control.py | |
parent | aa35021de10a78543c3320998acecba9f4851be0 (diff) | |
download | python-coveragepy-fb02cb27f17c619cf51acfc4c3c1f45817208523.tar.gz |
Warnings during measurement.
Diffstat (limited to 'coverage/control.py')
-rw-r--r-- | coverage/control.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/coverage/control.py b/coverage/control.py index a21a697..1268b3d 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -236,6 +236,10 @@ class coverage(object): print("should_trace: %r -> %r" % (filename, ret)) return ret + def _warn(self, msg): + """Use `msg` as a warning.""" + sys.stderr.write("Warning: " + msg + "\n") + def _abs_files(self, files): """Return a list of absolute file names for the names in `files`.""" files = files or [] @@ -260,7 +264,7 @@ class coverage(object): try: pkg_file = mod.__file__ except AttributeError: - print("WHOA! No file for module %s" % pkg) + self._warn("Module %s has no python source." % pkg) else: d, f = os.path.split(pkg_file) if f.startswith('__init__.'): @@ -318,8 +322,19 @@ class coverage(object): def stop(self): """Stop measuring code coverage.""" self.collector.stop() + + # If there are still entries in the source_pkgs list, then we never + # encountered those packages. + for pkg in self.source_pkgs: + self._warn("Source module %s was never encountered." % pkg) + self._harvest_data() + # Find out if we got any data. + summary = self.data.summary() + if not summary: + self._warn("No data was collected.") + def erase(self): """Erase previously-collected coverage data. |