diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2012-11-11 19:44:45 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2012-11-11 19:44:45 -0500 |
commit | 013f326263ef82c97259d6c6b69d0f62278cf3ae (patch) | |
tree | a584aac092652cc1bb398120d894a935dc2aa728 | |
parent | 06b941674b217683db6351fcb9f4fe717a90ef9e (diff) | |
download | python-coveragepy-git-013f326263ef82c97259d6c6b69d0f62278cf3ae.tar.gz |
No longer see a mysterious exception when not able to run code: AttributeError: 'NoneType' object has no attribute 'isabs'. #153
-rw-r--r-- | CHANGES.txt | 3 | ||||
-rw-r--r-- | coverage/cmdline.py | 2 | ||||
-rw-r--r-- | coverage/control.py | 6 | ||||
-rw-r--r-- | test/test_api.py | 1 | ||||
-rw-r--r-- | test/test_oddball.py | 1 | ||||
-rw-r--r-- | test/test_process.py | 2 |
6 files changed, 13 insertions, 2 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 87a75705..ead61c83 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -46,8 +46,11 @@ Version 3.5.4b1 - The pydoc tool can now show docmentation for the class `coverage.coverage`. Closes `issue 206`_. +- Other minor bugs fixed: `issue 153`_. + .. _issue 89: https://bitbucket.org/ned/coveragepy/issue/89/on-windows-all-packages-are-reported-in .. _issue 139: https://bitbucket.org/ned/coveragepy/issue/139/easy-check-for-a-certain-coverage-in-tests +.. _issue 153: https://bitbucket.org/ned/coveragepy/issue/153/non-existent-filename-triggers .. _issue 163: https://bitbucket.org/ned/coveragepy/issue/163/problem-with-include-and-omit-filename .. _issue 193: https://bitbucket.org/ned/coveragepy/issue/193/unicodedecodeerror-on-htmlpy .. _issue 201: https://bitbucket.org/ned/coveragepy/issue/201/coverage-using-django-14-with-pydb-on diff --git a/coverage/cmdline.py b/coverage/cmdline.py index f9b9b093..5217a313 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -562,8 +562,8 @@ class CoverageScript(object): code_ran = False raise finally: + self.coverage.stop() if code_ran: - self.coverage.stop() self.coverage.save() def do_debug(self, args): diff --git a/coverage/control.py b/coverage/control.py index 0391352d..effb4857 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -362,7 +362,6 @@ class coverage(object): def stop(self): """Stop measuring code coverage.""" self.collector.stop() - self._harvest_data() def erase(self): """Erase previously-collected coverage data. @@ -515,6 +514,7 @@ class coverage(object): Returns an `Analysis` object. """ + self._harvest_data() if not isinstance(it, CodeUnit): it = code_unit_factory(it, self.file_locator)[0] @@ -536,6 +536,7 @@ class coverage(object): Returns a float, the total percentage covered. """ + self._harvest_data() self.config.from_args( ignore_errors=ignore_errors, omit=omit, include=include, show_missing=show_missing, @@ -555,6 +556,7 @@ class coverage(object): See `coverage.report()` for other arguments. """ + self._harvest_data() self.config.from_args( ignore_errors=ignore_errors, omit=omit, include=include ) @@ -580,6 +582,7 @@ class coverage(object): Returns a float, the total percentage covered. """ + self._harvest_data() self.config.from_args( ignore_errors=ignore_errors, omit=omit, include=include, html_dir=directory, extra_css=extra_css, html_title=title, @@ -601,6 +604,7 @@ class coverage(object): Returns a float, the total percentage covered. """ + self._harvest_data() self.config.from_args( ignore_errors=ignore_errors, omit=omit, include=include, xml_output=outfile, diff --git a/test/test_api.py b/test/test_api.py index 4042d0a9..e2ebc656 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -429,6 +429,7 @@ class SourceOmitIncludeTest(OmitIncludeTestsMixin, CoverageTest): cov.start() import usepkgs # pylint: disable=F0401,W0612 cov.stop() + cov._harvest_data() # private! sshhh... summary = cov.data.summary() for k, v in list(summary.items()): assert k.endswith(".py") diff --git a/test/test_oddball.py b/test/test_oddball.py index 1a3bd22f..a8c243de 100644 --- a/test/test_oddball.py +++ b/test/test_oddball.py @@ -307,6 +307,7 @@ class ExceptionTest(CoverageTest): # Clean the line data and compare to expected results. # The filenames are absolute, so keep just the base. + cov._harvest_data() # private! sshhh... lines = cov.data.line_data() clean_lines = {} for f, llist in lines.items(): diff --git a/test/test_process.py b/test/test_process.py index d33dac59..259bf259 100644 --- a/test/test_process.py +++ b/test/test_process.py @@ -358,6 +358,7 @@ class ProcessTest(CoverageTest): out = self.run_command("coverage run i_dont_exist.py") self.assertIn("No file to run: 'i_dont_exist.py'", out) self.assertNotIn("warning", out) + self.assertNotIn("Exception", out) out = self.run_command("coverage run -m no_such_module") self.assertTrue( @@ -365,6 +366,7 @@ class ProcessTest(CoverageTest): ("No module named 'no_such_module'" in out) ) self.assertNotIn("warning", out) + self.assertNotIn("Exception", out) if sys.version_info >= (3, 0): # This only works on 3.x for now. # It only works with the C tracer. |