1. Ned Batchelder
  2. coverage.py
  3. Issues
Issue #217 duplicate

version 3.5.3 incorrectly trying to parse html files

Jonathan Kamens
created an issue

We just upgraded from coverage 3.5.1 to 3.5.3. We use coverage.py through nose, i.e., nosetests invokes coverage.py. Here's our nose configuration file:

# Coverage reporting
cover-package=qexec zipline

There are some HTML templates in qexec/web/templates. With 3.5.1, these are no trouble. With 3.5.3, however, coverage is attempting to parse them, and fails with this error on the first one:

File "/home/qexec/virtual_envs/qexec/lib/python2.7/site-packages/nose/plugins/cover.py", line 168, in report
  self.coverInstance.html_report(modules, self.coverHtmlDir)
File "/home/qexec/virtual_envs/qexec/lib/python2.7/site-packages/coverage/control.py", line 603, in html_report
File "/home/qexec/virtual_envs/qexec/lib/python2.7/site-packages/coverage/html.py", line 87, in report
  self.report_files(self.html_file, morfs, self.config.html_dir)
File "/home/qexec/virtual_envs/qexec/lib/python2.7/site-packages/coverage/report.py", line 83, in report_files
  report_fn(cu, self.coverage._analyze(cu))
File "/home/qexec/virtual_envs/qexec/lib/python2.7/site-packages/coverage/control.py", line 543, in _analyze
  return Analysis(self, it)
File "/home/qexec/virtual_envs/qexec/lib/python2.7/site-packages/coverage/results.py", line 30, in __init__
  self.statements, self.excluded = self.parser.parse_source()
File "/home/qexec/virtual_envs/qexec/lib/python2.7/site-packages/coverage/parser.py", line 202, in parse_source
File "/home/qexec/virtual_envs/qexec/lib/python2.7/site-packages/coverage/parser.py", line 106, in _raw_parse
  for toktype, ttext, (slineno, _), (elineno, _), ltext in tokgen:
File "/usr/lib64/python2.7/tokenize.py", line 351, in generate_tokens
  ("<tokenize>", lnum, pos, line))
File "<tokenize>", line 29
  {% endfor %}

I see that there is old discussion of a similar issue at https://groups.google.com/forum/?fromgroups=#!topic/coveragepy-dev/YvY-uaJWCyg . Is this a regression of some sort?

I tested 3.5.2, and the same problem occurs there, so I guess the issue was introduced between 3.5.1 and 3.5.2.


Comments (4)

  1. Ned Batchelder repo owner

    Jonathan, you don't include the actual exception at the end of the traceback, so I'm not sure, but the latest beta code (3.6b1, released last night!) has more fixes for this behavior, as bug #82 shows. Does your code fail with the latest beta? If not, please provide more information.

  2. Jonathan Kamens reporter

    Yes, it appears to be fixed in 3.6b1. Thanks.

    Sorry I forgot to include the actual error at the end of the stack trace. It was:

    IndentationError: unindent does not match any outer indentation level

    However, there's a new error in 3.6b1 that doesn't occur in 3.5.1:

      File "/home/qexec/virtual_envs/qexec/lib/python2.7/site-packages/nose/plugins/cover.py", line 158, in report
      File "/home/qexec/virtual_envs/qexec/lib/python2.7/site-packages/coverage/control.py", line 601, in html_report
    return reporter.report(morfs)
      File "/home/qexec/virtual_envs/qexec/lib/python2.7/site-packages/coverage/html.py", line 90, in report
    self.report_files(self.html_file, morfs, self.config.html_dir)
      File "/home/qexec/virtual_envs/qexec/lib/python2.7/site-packages/coverage/report.py", line 84, in report_files
    report_fn(cu, self.coverage._analyze(cu))
      File "/home/qexec/virtual_envs/qexec/lib/python2.7/site-packages/coverage/control.py", line 531, in _analyze
    return Analysis(self, it)
      File "/home/qexec/virtual_envs/qexec/lib/python2.7/site-packages/coverage/results.py", line 24, in __init__
    raise NoSource("No source for code: '%s'" % self.filename)
    coverage.misc.NoSource: No source for code: '/home/jik/repo/qexec/tests/loader/__init__.py'
  3. Jonathan Kamens reporter

    I think the issue with the new error shown above is that there was an init.py in that directory before, but it was removed, leaving behind an orphaned init.pyc. Still, this happened quite a while ago, and it just started producing an error from coverage with 3.6b1, so I think there's probably something in 3.6b1 that needs to be fixed.

  4. Log in to comment