Michael Hall has proposed merging 
lp:~mhall119/loco-directory/meeting-unicode-error into lp:loco-directory.

Requested reviews:
  loco-directory-dev (loco-directory-dev)

For more details, see:
https://code.launchpad.net/~mhall119/loco-directory/meeting-unicode-error/+merge/65810

Overview
========
If an agenda item's title contains unicode, it throws an exception when trying 
to convert the AgendaItem instance to a string.

Details
=======
This happens when calling unicode() on an AgendaItem, because it's __unicode__ 
method is actually returning an ascii string, not a unicode string.  Make sure 
that AgendaItem.__unicode__ returns a unicode string, rather than an ascii 
string.
-- 
https://code.launchpad.net/~mhall119/loco-directory/meeting-unicode-error/+merge/65810
Your team loco-directory-dev is requested to review the proposed merge of 
lp:~mhall119/loco-directory/meeting-unicode-error into lp:loco-directory.
=== modified file 'loco_directory/meetings/models.py'
--- loco_directory/meetings/models.py	2011-06-21 00:00:35 +0000
+++ loco_directory/meetings/models.py	2011-06-24 16:26:36 +0000
@@ -189,7 +189,7 @@
     
     def __unicode__(self):
         if self.parent is None:
-            return '%s' % self.title
+            return u'%s' % self.title
         else:
-            return '%s->%s' % (self.parent, self.title)
+            return u'%s->%s' % (self.parent, self.title)
     

=== modified file 'loco_directory/meetings/tests.py'
--- loco_directory/meetings/tests.py	2010-12-02 07:34:58 +0000
+++ loco_directory/meetings/tests.py	2011-06-24 16:26:36 +0000
@@ -6,18 +6,18 @@
 """
 
 from django.test import TestCase
-
-class SimpleTest(TestCase):
-    def test_basic_addition(self):
-        """
-        Tests that 1 + 1 always equals 2.
-        """
-        self.failUnlessEqual(1 + 1, 2)
-
-__test__ = {"doctest": """
-Another way to test that 1 + 1 is equal to 2.
-
->>> 1 + 1 == 2
-True
-"""}
-
+from meetings.models import AgendaItem
+
+
+class UnicodeTest(TestCase):
+
+    def setUp(self):
+        super(UnicodeTest, self).setUp()
+        self.test_string =  'test \xc3 string'
+
+    def test_unicode_agenda_title(self):
+        item = AgendaItem(title=self.test_string)
+        self.assertEquals(unicode(item), self.test_string)
+
+        child = AgendaItem(title=self.test_string, parent=item)
+        self.assertEquals(unicode(child), u'%s->%s' % (self.test_string, self.test_string))

_______________________________________________
Mailing list: https://launchpad.net/~loco-directory-dev
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~loco-directory-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to