From 3f1b714b7e767573b99fa167e62fa291738bf4e4 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 6 Nov 2010 16:49:23 -0400 Subject: Detect when our trace function is yanked out from under us, and warn the user. Finishes, but does not fix, issue #93. --- coverage/control.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'coverage/control.py') diff --git a/coverage/control.py b/coverage/control.py index cdaf9721..4fae198c 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -69,6 +69,9 @@ class coverage(object): """ from coverage import __version__ + # A record of all the warnings that have been issued. + self._warnings = [] + # Build our configuration from a number of sources: # 1: defaults: self.config = CoverageConfig() @@ -120,7 +123,7 @@ class coverage(object): self.collector = Collector( self._should_trace, timid=self.config.timid, - branch=self.config.branch + branch=self.config.branch, warn=self._warn ) # Suffixes are a bit tricky. We want to use the data suffix only when @@ -274,7 +277,8 @@ class coverage(object): def _warn(self, msg): """Use `msg` as a warning.""" - sys.stderr.write("Coverage.py warning: " + msg + "\n") + self._warnings.append(msg) + sys.stderr.write("Coverage.py warning: %s\n" % msg) def _abs_files(self, files): """Return a list of absolute file names for the names in `files`.""" -- cgit v1.2.1