本文整理汇总了Python中mgi.tests.DataHandler.get_html2方法的典型用法代码示例。如果您正苦于以下问题:Python DataHandler.get_html2方法的具体用法?Python DataHandler.get_html2怎么用?Python DataHandler.get_html2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mgi.tests.DataHandler
的用法示例。
在下文中一共展示了DataHandler.get_html2方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AbstractRenderUlTestSuite
# 需要导入模块: from mgi.tests import DataHandler [as 别名]
# 或者: from mgi.tests.DataHandler import get_html2 [as 别名]
class AbstractRenderUlTestSuite(TestCase):
def setUp(self):
ul_data = join('utils', 'XSDParser', 'tests', 'data', 'renderer', 'default', 'ul')
self.ul_data_handler = DataHandler(ul_data)
self.types_generator = VariableTypesGenerator()
self.content = '<li>lorem ipsum</li>'
def test_elem_id_str_chosen_true(self):
element_id = 'string'
chosen = True
result_string = render_ul(self.content, element_id, chosen)
self.assertEqual(result_string, render_ul(unicode(self.content), unicode(element_id), chosen))
# print result_string
result_html = etree.fromstring(result_string)
expected_html = self.ul_data_handler.get_html2('elem_str_ch_true')
self.assertTrue(are_equals(result_html, expected_html))
def test_elem_id_str_chosen_false(self):
element_id = 'string'
chosen = False
result_string = render_ul(self.content, element_id, chosen)
self.assertEqual(result_string, render_ul(unicode(self.content), unicode(element_id), chosen))
# print result_string
result_html = etree.fromstring(result_string)
expected_html = self.ul_data_handler.get_html2('elem_str_ch_false')
self.assertTrue(are_equals(result_html, expected_html))
def test_elem_id_empty_str_chosen_true(self):
element_id = ''
chosen = True
result_string = render_ul(self.content, element_id, chosen)
self.assertEqual(result_string, render_ul(unicode(self.content), unicode(element_id), chosen))
# print result_string
result_html = etree.fromstring(result_string)
expected_html = self.ul_data_handler.get_html2('elem_empty_ch_true')
self.assertTrue(are_equals(result_html, expected_html))
def test_elem_id_empty_str_chosen_false(self):
element_id = ''
chosen = False
result_string = render_ul(self.content, element_id, chosen)
self.assertEqual(result_string, render_ul(unicode(self.content), unicode(element_id), chosen))
# print result_string
result_html = etree.fromstring(result_string)
expected_html = self.ul_data_handler.get_html2('elem_empty_ch_false')
self.assertTrue(are_equals(result_html, expected_html))
def test_elem_id_none_chosen_true(self):
element_id = None
chosen = True
result_string = render_ul(self.content, element_id, chosen)
self.assertEqual(result_string, render_ul(unicode(self.content), element_id, chosen))
# print result_string
result_html = etree.fromstring(result_string)
expected_html = self.ul_data_handler.get_html2('elem_none_ch_true')
self.assertTrue(are_equals(result_html, expected_html))
def test_elem_id_none_chosen_false(self):
element_id = 'string'
chosen = True
result_string = render_ul(self.content, element_id, chosen)
self.assertEqual(result_string, render_ul(unicode(self.content), element_id, chosen))
# print result_string
result_html = etree.fromstring(result_string)
expected_html = self.ul_data_handler.get_html2('elem_str_ch_true')
self.assertTrue(are_equals(result_html, expected_html))
def test_content_not_str(self):
content = 'string'
element_id = 'string'
chosen = True
try:
for content in self.types_generator.generate_types_excluding(['str', 'unicode']):
with self.assertRaises(Exception):
render_ul(content, element_id, chosen)
except AssertionError as error:
content_type = str(type(content))
error.message += ' (content type: ' + content_type + ')'
raise AssertionError(error.message)
#.........这里部分代码省略.........