Commits

Ned Batchelder  committed 02e9288

No longer see a mysterious exception when not able to run code: AttributeError: 'NoneType' object has no attribute 'isabs'. #153

  • Participants
  • Parent commits 92e5211

Comments (0)

Files changed (6)

 - 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

File coverage/cmdline.py

                 code_ran = False
                 raise
         finally:
+            self.coverage.stop()
             if code_ran:
-                self.coverage.stop()
                 self.coverage.save()
 
     def do_debug(self, args):

File coverage/control.py

     def stop(self):
         """Stop measuring code coverage."""
         self.collector.stop()
-        self._harvest_data()
 
     def erase(self):
         """Erase previously-collected coverage data.
         Returns an `Analysis` object.
 
         """
+        self._harvest_data()
         if not isinstance(it, CodeUnit):
             it = code_unit_factory(it, self.file_locator)[0]
 
         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,
         See `coverage.report()` for other arguments.
 
         """
+        self._harvest_data()
         self.config.from_args(
             ignore_errors=ignore_errors, omit=omit, include=include
             )
         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,
         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,

File test/test_api.py

         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")

File test/test_oddball.py

 
             # 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():

File test/test_process.py

         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(
             ("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.