Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-existent filename triggers AttributeError. #153

Closed
nedbat opened this issue Oct 17, 2011 · 2 comments
Closed

Non-existent filename triggers AttributeError. #153

nedbat opened this issue Oct 17, 2011 · 2 comments
Labels
bug Something isn't working run

Comments

@nedbat
Copy link
Owner

nedbat commented Oct 17, 2011

Originally reported by Julian O (Bitbucket: oddthinking, GitHub: oddthinking)


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
Coverage.py, version 3.5.1.  http://nedbatchelder.com/code/coverage

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


@nedbat
Copy link
Owner Author

nedbat commented May 17, 2012

Original comment by Brodie Rao (Bitbucket: brodie, GitHub: brodie)


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: https://bitbucket.org/ned/coveragepy/changeset/edfe23dc34d3

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

#!diff
diff --git a/coverage/html.py b/coverage/html.py
--- a/coverage/html.py
+++ b/coverage/html.py
@@ -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):
         self.directory = 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,
             }

@nedbat
Copy link
Owner Author

nedbat commented Nov 12, 2012

Fixed in <<changeset 02e92889a5eb (bb)>>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working run
Projects
None yet
Development

No branches or pull requests

1 participant