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

HTML report fails with 'int' object is unsubscriptable #59

Closed
nedbat opened this issue Apr 8, 2010 · 2 comments
Closed

HTML report fails with 'int' object is unsubscriptable #59

nedbat opened this issue Apr 8, 2010 · 2 comments
Labels
bug Something isn't working

Comments

@nedbat
Copy link
Owner

nedbat commented Apr 8, 2010

Hi all,

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

#!python

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?

Jean-Paul


@nedbat
Copy link
Owner Author

nedbat commented Apr 8, 2010

Original comment by Jean-Paul Calderone (Bitbucket: exarkun, GitHub: exarkun)


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).

@nedbat
Copy link
Owner Author

nedbat commented Jun 4, 2010

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 <<changeset 99a25749a8d2 (bb)>>, I fixed coverage.py to return a nice exception ("No data to report") rather than trip over itself with subscripted ints.

@nedbat nedbat closed this as completed Jun 4, 2010
@nedbat nedbat added major bug Something isn't working labels Jun 23, 2018
agronholm pushed a commit to agronholm/coveragepy that referenced this issue Aug 16, 2020
Check all parents for cancellation, not just the immediate one.

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

No branches or pull requests

1 participant