>> Aaah! :-(
>>
>> I've been fighting this problem a bit when testing with MySQL, too,
>> because my system creates the databases in LATIN1 if I don't tell it
>> anything special and so the test database can't hold the full unicode
>> range of characters. It creates PostgreSQL database in UTF-8 on my end,
>> though, so I've never seen it with that database.
>>
>> Okay... time to fix that problem then. Probably need to introduce a
>> settings for tests only for database encoding. I should have done that
>> when I first saw the problem instead of trying to dodge around it.
>>
>> I hate it when being lazy doesn't work. :-(
>>
>> I'll put this one on my list. Nice debugging job. Thanks.

Hello again,
I temporarily patched Django source code (django/test/utils.py, lines 96 
and 107) to:

   cursor.execute("CREATE DATABASE %s WITH ENCODING 'UNICODE'" % 
backend.quote_name(TEST_DATABASE_NAME))

So, now I could run my tests. And here is some experience which I get 
during debuging (my advices are dedicated mainly for other testers; I am 
developing application in Czech language, in utf-8 encoding):

* check *all* your strings (I have a lot of strings like 'něco' or 
'%s-123' % var; most of them I must to rewrite to u'něco' and u'%s-123' 
% var); check them on all possible places (models, views, tests, 
settings, custom tags, ...)

* if you use Client in test (django.test.client), make sure, that you 
recode content with smart_unicode function. For example:
   response = self.submitHelper('www.example.com')
   self.failUnlessEqual(response.status_code, 200)
   self.failUnless(smart_unicode(response.content).find(u'nějaký 
rětězec') != -1)

* make sure, that data, which you post via client.post, are correctly 
encoded. For example:
   post_data = {
     'item1': u"První položka",
     'item2': u"Druhá položka",
     'item3': u"Třetí položka"
   }
   response = self.client.post('/url/', post_data)

Hope this will help to somebody.

Regards
Michal

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to