Commit 195cea91 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

test: ignore the order or attributes in HTML element assertion.

parent 6832d07a
# -*- coding: utf-8 -*-
import unittest, re
from lxml import etree
from DateTime import DateTime
import Zope2
......@@ -122,9 +123,12 @@ class FormTestCase(unittest.TestCase):
.manage_addField('date_time','Test Field','DateTimeField')
field = self.form.date_time
field._edit({'timezone_style': 0})
self.assertFalse('<select size="1" name="subfield_field_date_time_timezone" >' in field.render())
parser = etree.HTMLParser()
e = etree.fromstring(field.render(), parser=parser)
self.assertFalse(e.xpath('//select[@size="1"][@name="subfield_field_date_time_timezone"]'))
field._edit({'timezone_style': 1})
self.assertTrue('<select size="1" name="subfield_field_date_time_timezone" >' in field.render())
e = etree.fromstring(field.render(), parser=parser)
self.assertTrue(e.xpath('//select[@size="1"][@name="subfield_field_date_time_timezone"]'))
def test_datetime_css_class_rendering(self):
......@@ -181,13 +185,18 @@ class FormTestCase(unittest.TestCase):
.manage_addField('date_time','Test Field','DateTimeField')
field = self.form.date_time
field._edit({'input_style': 'number'})
self.assertTrue('<input name="subfield_field_date_time_year" value="" maxlength="4" type="number" size="4" min="0" max="9999" />' in field.render())
parser = etree.HTMLParser()
e = etree.fromstring(field.render(), parser=parser)
self.assertTrue(e.xpath('//input[@name="subfield_field_date_time_year"][@value=""][@maxlength="4"][@type="number"][@size="4"][@min="0"][@max="9999"]'))
field._edit({'start_datetime': DateTime('1900/01/01'), 'end_datetime': None})
self.assertTrue('<input name="subfield_field_date_time_year" value="" maxlength="4" type="number" size="4" min="1900" max="9999" />' in field.render())
e = etree.fromstring(field.render(), parser=parser)
self.assertTrue(e.xpath('//input[@name="subfield_field_date_time_year"][@value=""][@maxlength="4"][@type="number"][@size="4"][@min="1900"][@max="9999"]'))
field._edit({'start_datetime': None, 'end_datetime': DateTime('2099/12/31')})
self.assertTrue('<input name="subfield_field_date_time_year" value="" maxlength="4" type="number" size="4" min="0" max="2099" />' in field.render())
e = etree.fromstring(field.render(), parser=parser)
self.assertTrue(e.xpath('//input[@name="subfield_field_date_time_year"][@value=""][@maxlength="4"][@type="number"][@size="4"][@min="0"][@max="2099"]'))
field._edit({'start_datetime': DateTime('1900/01/01'), 'end_datetime': DateTime('2099/12/31')})
self.assertTrue('<input name="subfield_field_date_time_year" value="" maxlength="4" type="number" size="4" min="1900" max="2099" />' in field.render())
e = etree.fromstring(field.render(), parser=parser)
self.assertTrue(e.xpath('//input[@name="subfield_field_date_time_year"][@value=""][@maxlength="4"][@type="number"][@size="4"][@min="1900"][@max="2099"]'))
def test_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