Non-existent filename triggers AttributeError.

Issue #153 resolved
Julian O created an issue

Running coverage on a non-existent file gives a meaningful error message, and then signs off with an unexpected exception report.

I hope the following test case says it all:


coverage run a_file_that_does_not_exist No file to run: 'a_file_that_does_not_exist' Exception AttributeError: "'NoneType' object has no attribute 'isabs'" in <function _remove at 0x026E23F0> ignored

ver Microsoft Windows [Version 6.0.6002]

python --version Python 2.7.1

coverage --version, version 3.5.1. }}}

Obviously, this isn't a big problem, but worth noting.

Comments (3)

  1. Brodie Rao

    On a somewhat related note, I'm seeing this exact warning when running the Mercurial test suite with coverage 3.5.2. As far as I know, Mercurial's test runner doesn't try to run non-existent tests.

    I don't fully understand what's going on, but I've bisected the problem down to this commit:

    Again, I have no idea what I'm doing, but this seemingly silly change gets rid of the problem:

    diff --git a/coverage/ b/coverage/
    --- a/coverage/
    +++ b/coverage/
    @@ -2,7 +2,7 @@
     import os, re, shutil, sys
    -import coverage
    +from coverage import __url__, __version__
     from coverage.backward import pickle
     from coverage.misc import CoverageException, Hasher
     from coverage.phystokens import source_token_lines, source_encoding
    @@ -46,8 +46,8 @@ class HtmlReporter(Reporter):
    = None
             self.template_globals = {
                 'escape': escape,
    -            '__url__': coverage.__url__,
    -            '__version__': coverage.__version__,
    +            '__url__': __url__,
    +            '__version__': __version__,
             self.source_tmpl = Templite(
                 data("htmlfiles/pyfile.html"), self.template_globals
    @@ -287,7 +287,7 @@ class HtmlStatus(object):
                 usable = True
                 if status['format'] != self.STATUS_FORMAT:
                     usable = False
    -            elif status['version'] != coverage.__version__:
    +            elif status['version'] != __version__:
                     usable = False
             if usable:
    @@ -301,7 +301,7 @@ class HtmlStatus(object):
             status_file = os.path.join(directory, self.STATUS_FILE)
             status = {
                 'format': self.STATUS_FORMAT,
    -            'version': coverage.__version__,
    +            'version': __version__,
                 'settings': self.settings,
                 'files': self.files,
  2. Log in to comment