fix encoding error on Zope 2.12 and make each synthetic test runnable individually

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31788 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 659b7217
...@@ -292,6 +292,9 @@ class W3Validator(object): ...@@ -292,6 +292,9 @@ class W3Validator(object):
''' '''
retrun two list : a list of errors and an other for warnings retrun two list : a list of errors and an other for warnings
''' '''
if isinstance(page_source, unicode):
# Zope 2.12 renders page templates as unicode
page_source = page_source.encode('utf-8')
source = 'fragment=%s&output=soap12' % urllib.quote_plus(page_source) source = 'fragment=%s&output=soap12' % urllib.quote_plus(page_source)
os.environ['CONTENT_LENGTH'] = str(len(source)) os.environ['CONTENT_LENGTH'] = str(len(source))
os.environ['REQUEST_METHOD'] = 'POST' os.environ['REQUEST_METHOD'] = 'POST'
...@@ -442,7 +445,11 @@ def testPortalTypeViewRecursivly(validator, module_id, business_template_info, ...@@ -442,7 +445,11 @@ def testPortalTypeViewRecursivly(validator, module_id, business_template_info,
portal_path, portal_path,
view_name, view_name,
business_template_info.title) business_template_info.title)
method_name = 'test.%s.%s.%s' % (business_template_info.title, portal_type, view_name) method_name = ('test_%s_%s_%s' %
(business_template_info.title,
str(portal_type).replace(' ','_'), # can be unicode
view_name))
method.__name__ = method_name
setattr(TestXHTML, method_name, method) setattr(TestXHTML, method_name, method)
module_id = backuped_module_id module_id = backuped_module_id
business_template_info = backuped_business_template_info business_template_info = backuped_business_template_info
...@@ -555,13 +562,14 @@ elif validator_to_use == 'tidy': ...@@ -555,13 +562,14 @@ elif validator_to_use == 'tidy':
else: else:
validator = TidyValidator(validator_path, show_warnings) validator = TidyValidator(validator_path, show_warnings)
def test_suite(): if validator is not None:
# add the tests
if validator is not None:
# add erp5_core to the list here to not return it # add erp5_core to the list here to not return it
# on getBusinessTemplateList call # on getBusinessTemplateList call
addTestMethodDynamically(validator, addTestMethodDynamically(validator,
('erp5_core',) + TestXHTML.getBusinessTemplateList()) ('erp5_core',) + TestXHTML.getBusinessTemplateList())
def test_suite():
# add the tests
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestXHTML)) suite.addTest(unittest.makeSuite(TestXHTML))
return suite return suite
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment