Commits

James Crasta committed fa0d787

Minor changes to tests for python3.2 support.

Comments (0)

Files changed (3)

 from wtforms.form import Form
 
 
-PYTHON_VERSION = platform.python_version_tuple()
+PYTHON_VERSION = tuple(int(x) for x in platform.python_version_tuple())
 
 class DummyPostData(dict):
     def getlist(self, key):
         self.assertEqual(unicode(label), expected)
         self.assertEqual(label.__html__(), expected)
         self.assertEqual(label().__html__(), expected)
-        self.assertEqual(label('hello'), u"""<label for="test">hello</label>""")
+        self.assertEqual(label(u'hello'), u"""<label for="test">hello</label>""")
         self.assertEqual(TextField(u'hi').bind(Form(), 'a').label.text, u'hi')
-        self.assertEqual(repr(label), "Label('test', u'Caption')") 
+        if PYTHON_VERSION < (3, 0, 0):
+            self.assertEqual(repr(label), "Label('test', u'Caption')") 
+        else:
+            self.assertEqual(repr(label), "Label('test', 'Caption')") 
 
     def test_auto_label(self):
-        t1 = TextField().bind(Form(), 'foo_bar')
-        self.assertEqual(t1.label.text, 'Foo Bar')
+        t1 = TextField().bind(Form(), u'foo_bar')
+        self.assertEqual(t1.label.text, u'Foo Bar')
 
-        t2 = TextField('').bind(Form(), 'foo_bar')
-        self.assertEqual(t2.label.text, '')
+        t2 = TextField(u'').bind(Form(), u'foo_bar')
+        self.assertEqual(t2.label.text, u'')
 
 
 class FlagsTest(TestCase):
     def test_microseconds(self):
         if PYTHON_VERSION < (2, 6, 0):
             return # Microsecond formatting support was only added in 2.6
-        
+
         d = datetime(2011, 5, 7, 3, 23, 14, 424200)
         F = make_form(a=DateTimeField(format='%Y-%m-%d %H:%M:%S.%f'))
         form = F(DummyPostData(a=['2011-05-07 03:23:14.4242']))
 
     _value       = lambda x: x.data
     __unicode__  = lambda x: x.data
+    __str__      = lambda x: x.data
     __call__     = lambda x, **k: x.data
     __iter__     = lambda x: iter(x.data)
     iter_choices = lambda x: iter(x.data)
         self._errors = None
         self._fields = {}
 
-        if hasattr(fields, 'iteritems'):
-            fields = fields.iteritems()
+        if hasattr(fields, 'items'):
+            fields = fields.items()
 
         translations = self._get_translations()