diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2011-02-07 08:37:14 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2011-02-07 08:37:14 -0500 |
commit | 6ec3302004a2293535e5c3814c1c19e2f141e972 (patch) | |
tree | 029b370254f2d0f387aabdd41514285af2dd4d81 /coverage/cmdline.py | |
parent | cd308cf6b980dd83e56c4739db298a631ed14262 (diff) | |
download | python-coveragepy-6ec3302004a2293535e5c3814c1c19e2f141e972.tar.gz |
Don't warn about not collecting data if we never ran any code in the first place.
Diffstat (limited to 'coverage/cmdline.py')
-rw-r--r-- | coverage/cmdline.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/coverage/cmdline.py b/coverage/cmdline.py index cdcf317..b739afa 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -4,7 +4,7 @@ import optparse, re, sys, traceback from coverage.backward import sorted # pylint: disable=W0622 from coverage.execfile import run_python_file, run_python_module -from coverage.misc import CoverageException, ExceptionDuringRun +from coverage.misc import CoverageException, ExceptionDuringRun, NoSource class Opts(object): @@ -511,13 +511,18 @@ class CoverageScript(object): if 'execute' in options.actions: # Run the script. self.coverage.start() + never_run = False try: - if options.module: - self.run_python_module(args[0], args) - else: - self.run_python_file(args[0], args) + try: + if options.module: + self.run_python_module(args[0], args) + else: + self.run_python_file(args[0], args) + except NoSource: + never_run = True + raise finally: - self.coverage.stop() + self.coverage.stop(never_run) self.coverage.save() if 'combine' in options.actions: |