From f32d638d5845d55f7e027c9b88583513b31871f8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Thu, 10 Dec 2015 14:11:21 +0100
Subject: [PATCH] tests: make sure ui test page templates can be rendered

In case there is an error in the TALES experession and the page cannot
be rendered, then this page will silently be ignored.
---
 .../tests/ERP5TypeFunctionalTestCase.py       | 25 ++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/product/ERP5Type/tests/ERP5TypeFunctionalTestCase.py b/product/ERP5Type/tests/ERP5TypeFunctionalTestCase.py
index 12bd983d74..d48b576497 100644
--- a/product/ERP5Type/tests/ERP5TypeFunctionalTestCase.py
+++ b/product/ERP5Type/tests/ERP5TypeFunctionalTestCase.py
@@ -35,6 +35,7 @@ import subprocess
 import shutil
 import transaction
 from ZPublisher.HTTPResponse import HTTPResponse
+from zExceptions.ExceptionFormatter import format_exception
 from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase, \
                                                _getConversionServerDict
 
@@ -405,8 +406,30 @@ class ERP5TypeFunctionalTestCase(ERP5TypeTestCase):
         return True
     return False
 
+  def testCheckZuitePageTemplatesValidHTML(self):
+    # Check the zuite page templates can be rendered, because selenium test
+    # runner does not report error in case there are errors in the page
+    # template.
+    tests_tool = self.portal.portal_tests
+    for page_template_path, page_template in tests_tool.ZopeFind(
+              tests_tool, obj_metatypes=['Page Template'], search_sub=1):
+      try:
+        page_template.pt_render()
+      except (KeyboardInterrupt, SystemExit):
+        raise
+      except:
+        exc_type, exc_value, exc_traceback = sys.exc_info()
+        self.fail('Rendering of %s failed with error:\n%s' % (
+          page_template_path,
+          ''.join(format_exception(
+            exc_type,
+            exc_value,
+            exc_traceback,
+            as_html=False))))
+
+
   def testFunctionalTestRunner(self):
-    # first of all, abort to get rid of the mysql participation inn this
+    # first of all, abort to get rid of the mysql participation in this
     # transaction
     self.portal._p_jar.sync()
 
-- 
GitLab