1. Ned Batchelder
  2. coverage.py
Issue #76 resolved

html reporting fails on Python 3.2 and 2.7

Brett Cannon
created an issue

I am trying to use coverage.py to test importlib (a pure Python implementation of import in Python 3.1). I would love to have html output to more easily see what is not being executed, but every time I try to generate html code, I get an error (ignore the runpy stuff; modified coverage.py to run with the -m flag so that I could easily run in-place in my svn checkout of Python): {{{

!python

File "/Users/brett/Dev/python/3.x/importlib_abc_fixes/Lib/runpy.py", line 160, in _run_module_as_main "main", fname, loader, pkg_name) File "/Users/brett/Dev/python/3.x/importlib_abc_fixes/Lib/runpy.py", line 73, in _run_code exec(code, run_globals) File "/Users/brett/Dev/python/3.x/importlib_abc_fixes/coverage/main.py", line 3, in <module> cmdline.main() File "coverage/cmdline.py", line 601, in main status = CoverageScript().command_line(argv) File "coverage/cmdline.py", line 507, in command_line directory=options.directory, **report_args) File "coverage/control.py", line 362, in html_report omit_prefixes=self.config.omit_prefixes File "coverage/html.py", line 45, in report self.report_files(self.html_file, morfs, directory, omit_prefixes) File "coverage/report.py", line 57, in report_files report_fn(cu, self.coverage._analyze(cu)) File "coverage/html.py", line 67, in html_file missing_branch_arcs = analysis.missing_branch_arcs() File "coverage/results.py", line 112, in missing_branch_arcs missing = self.arcs_missing() File "coverage/results.py", line 78, in arcs_missing possible = self.arc_possibilities() File "coverage/results.py", line 67, in arc_possibilities return self.parser.arcs() File "coverage/misc.py", line 58, in _wrapped setattr(self, attr, fn(self)) File "coverage/parser.py", line 200, in arcs for l1, l2 in self.byte_parser._all_arcs(): File "coverage/parser.py", line 586, in _all_arcs arcs.update(bp._arcs()) File "coverage/parser.py", line 505, in _arcs chunks = self._split_into_chunks() File "coverage/parser.py", line 443, in _split_into_chunks block_stack.pop() IndexError: pop from empty list

}}}

My best guess is that coverage.py does not like the fact that some test files get imported that do not exist at html creation time since they were temporary (or never actually existed in the first place; I use fake file paths for files that are never created). This is not preventing the normal report output from working; it's only affecting the html output.

Comments (6)

  1. Anonymous

    I'm seeing a problem that seems to match up with the ticket summary, but I don't get the same traceback as Brett reported. Instead, I see this error:

    No source for code: '/tmp/test_reflect.py (macro)>': [Errno 2] No such file or directory: '/tmp/test_reflect.py (macro)>'

    Which seems to stop `coverage html ...`. The resulting htmlcov directory doesn't have an index or the css file.

  2. Ned Batchelder repo owner

    Anonymous: use the -i switch on the html command, or send me a reproducible case. Your filename has "(macro) >" in it, which is odd, what produces that? Also, giving me a way to get in touch with you would also help.

  3. Log in to comment