1. Ned Batchelder
  2. coverage.py
  3. Issues
Issue #59 resolved

HTML report fails with 'int' object is unsubscriptable

Ned Batchelder
repo owner created an issue

Hi all,

Running coverage html, I'm running into this exception:



Traceback (most recent call last): File "/srv/bb-master/.local/bin/coverage", line 8, in <module> load_entry_point('coverage==3.3.1', 'console_scripts', 'coverage')() File "/srv/bb-master/.local/lib/python2.5/site- packages/coverage-3.3.1-py2.5-linux-i686.egg/coverage/cmdline.py", line 601, in main status = CoverageScript().command_line(argv) File "/srv/bb-master/.local/lib/python2.5/site- packages/coverage-3.3.1-py2.5-linux-i686.egg/coverage/cmdline.py", line 507, in command_line directory=options.directory, **report_args) File "/srv/bb-master/.local/lib/python2.5/site- packages/coverage-3.3.1-py2.5-linux-i686.egg/coverage/control.py", line 362, in html_report omit_prefixes=self.config.omit_prefixes File "/srv/bb-master/.local/lib/python2.5/site- packages/coverage-3.3.1-py2.5-linux-i686.egg/coverage/html.py", line 48, in report self.index_file() File "/srv/bb-master/.local/lib/python2.5/site- packages/coverage-3.3.1-py2.5-linux-i686.egg/coverage/html.py", line 153, in index_file fhtml.write(index_tmpl.render(locals())) File "/srv/bb-master/.local/lib/python2.5/site- packages/coverage-3.3.1-py2.5-linux-i686.egg/coverage/templite.py", line 103, in render engine.execute(self.ops) File "/srv/bb-master/.local/lib/python2.5/site- packages/coverage-3.3.1-py2.5-linux-i686.egg/coverage/templite.py", line 129, in execute raise new_exc TypeError: Couldn't evaluate {{ totals.pc_covered|format_pct }}: 'int' object is unsubscriptable


Anyone know what's wrong?


Comments (2)

  1. Jean-Paul Calderone

    Attached is a .coverage file with which I can reproduce this issue. It was generated on an Ubuntu Hardy machine by generating coverage for Twisted. In a Twisted trunk@28817 checkout, this command was run:

    coverage run ./bin/trial --reporter=bwverbose twisted

    Coverage 3.3.1 was used (installed from source, as that version is not packaged for Hardy AFAICT), along with Python 2.5.2 (Hardy packaged version). The resulting file was then transferred to another Ubuntu Hardy machine and an html report generated using this command:

    coverage html -d twisted-coverage --omit /usr,/srv/bb-slave/.local,/srv/bb-slave/Projects,/srv/bb-slave/Run/slave/twisted-coverage.py/Twisted/_trial_temp -i

    As you might guess from the omit arguments, the Twisted checkout was in /srv/bb-slave/Run/slave/twisted-coverage.py/Twisted.

    The second machine also had Coverage 3.3.1 installed, as well as Python 2.5.2 (Hardy packaged version).

  2. Ned Batchelder reporter

    This is because for whatever reason, your HTML report has no files in it. You must be over-constraining the report, or not measuring any data at all somehow.

    In 99a25749a8d2 , I fixed coverage.py to return a nice exception ("No data to report") rather than trip over itself with subscripted ints.

  3. Log in to comment