[view] display colorized recipe in test report (closes #3241604)
uses pygments (also add dependency). The imported "pygments.css" file is
available in cubicweb.
--- a/__pkginfo__.py Tue Aug 20 16:07:48 2013 +0200
+++ b/__pkginfo__.py Tue Aug 20 10:22:39 2013 +0200
@@ -24,6 +24,7 @@
'cubicweb-vcsfile': '>= 1.12',
'cubicweb-file': None,
'cubicweb-narval': '>= 4',
+ 'Pygments': None,
}
__recommends__ = {'cubicweb-tracker': None,
'cubicweb-nosylist': '>= 0.5.0',
--- a/debian/control Tue Aug 20 16:07:48 2013 +0200
+++ b/debian/control Tue Aug 20 10:22:39 2013 +0200
@@ -13,7 +13,7 @@
Package: cubicweb-apycot
Architecture: all
XB-Python-Version: ${python:Versions}
-Depends: ${misc:Depends}, ${python:Depends}, cubicweb-common (>= 3.14.0), cubicweb-vcsfile (>= 1.12), cubicweb-file (>= 1.8.2), cubicweb-narval (>= 3.0.2), pyro
+Depends: ${misc:Depends}, ${python:Depends}, cubicweb-common (>= 3.14.0), cubicweb-vcsfile (>= 1.12), cubicweb-file (>= 1.8.2), cubicweb-narval (>= 3.0.2), pyro, python-pygments
Recommends: cubicweb-jqplot (>= 0.1.2)
Suggests: cubicweb-tracker, cubicweb-nosylist (>= 0.5.0)
Description: apycot component for the CubicWeb framework
--- a/views/testexecution.py Tue Aug 20 16:07:48 2013 +0200
+++ b/views/testexecution.py Tue Aug 20 10:22:39 2013 +0200
@@ -10,6 +10,10 @@
from datetime import datetime
+from pygments import highlight
+from pygments.lexers import PythonLexer
+from pygments.formatters import HtmlFormatter
+
from logilab.mtconverter import xml_escape
from cubicweb import Unauthorized, tags
@@ -38,7 +42,6 @@
self.wview('table', rset, 'null', title=title, displaycols=range(1, 4),
divid='info%s'%entity.eid)
-
class ChecksDescriptorMixin(object):
def describe_execution(self, exc, changes_only=False, xml_compat=False):
self._cw.add_css('cubes.apycot.css')
@@ -163,7 +166,7 @@
_pvs.tag_subject_of(('TestExecution', 'log_file', '*'), 'hidden')
_pvs.tag_subject_of(('TestExecution', 'execution_of', '*'), 'hidden')
_pvs.tag_object_of(('*', 'during_execution', 'TestExecution'), 'hidden')
-
+_pvs.tag_attribute(('TestExecution', 'script'), 'hidden')
class TEPrimaryView(tabs.TabbedPrimaryView):
__select__ = is_instance('TestExecution')
@@ -211,7 +214,14 @@
return # user can't read repositories for instance
self.wview('table', rset, 'null', title=title, divid='vc%s'%entity.eid)
+ def display_recipe(self,entity):
+ self._cw.add_css('pygments.css')
+ title = self._cw._('recipe information')
+ self.w('<h2>%s</h2>' % title)
+ self.w(highlight(entity.script, PythonLexer(), HtmlFormatter()))
+
def render_entity_relations(self, entity):
+ self.display_recipe(entity)
self.display_version_configuration(entity)
self.display_info_section(entity)
super(TEConfigTab, self).render_entity_relations(entity)