Issue #37 resolved

Coverage html/xml report fail when no coverage datas found

cjulien
created an issue

Yes, this is stupid ;) , but when launching coverage html without any .coverage file created, coverage fail with an exception like this :

{{{ Traceback (most recent call last): File "/usr/bin/coverage", line 7, in ? sys.exit( File "/usr/lib/python2.4/site-packages/coverage-3.2b2-py2.4-linux-i686.egg/coverage/cmdline.py", line 572, in main status = CoverageScript().command_line(sys.argv[1:]) File "/usr/lib/python2.4/site-packages/coverage-3.2b2-py2.4-linux-i686.egg/coverage/cmdline.py", line 480, in command_line self.coverage.html_report( File "/usr/lib/python2.4/site-packages/coverage-3.2b2-py2.4-linux-i686.egg/coverage/control.py", line 295, in html_report reporter.report( File "/usr/lib/python2.4/site-packages/coverage-3.2b2-py2.4-linux-i686.egg/coverage/html.py", line 48, in report self.index_file() File "/usr/lib/python2.4/site-packages/coverage-3.2b2-py2.4-linux-i686.egg/coverage/html.py", line 139, in index_file fhtml.write(index_tmpl.render(locals())) File "/usr/lib/python2.4/site-packages/coverage-3.2b2-py2.4-linux-i686.egg/coverage/templite.py", line 103, in render engine.execute(self.ops) File "/usr/lib/python2.4/site-packages/coverage-3.2b2-py2.4-linux-i686.egg/coverage/templite.py", line 123, in execute self.result += str(self.evaluate(args)) File "/usr/lib/python2.4/site-packages/coverage-3.2b2-py2.4-linux-i686.egg/coverage/templite.py", line 145, in evaluate value = self.evaluate(pipes[0]) File "/usr/lib/python2.4/site-packages/coverage-3.2b2-py2.4-linux-i686.egg/coverage/templite.py", line 156, in evaluate value = value[dot] TypeError: unsubscriptable object }}}

I made a simple workaround to continue to use it like this : {{{ --- ned/coverage/templite.py 2009-11-20 15:35:53.000000000 +0100 +++ dev/coverage/templite.py 2009-11-20 15:36:52.000000000 +0100 @@ -152,7 +133,10 @@ try: value = getattr(value, dot) except AttributeError: + try : value = value[dot] + except TypeError: + return value if hasattr(value, 'call'): value = value() else: }}}

Comments (1)

  1. Log in to comment