Hmm, I've figured how to inspect context in the test by reading django sources. But that didn't help greatly, because context['translation'].content (translation is a model for translated pages content) still returns doubly encoded utf-8 data. By the way, the page in browser is rendered correctly. Does anyone has suggestions how to test i18n features in Django apps? Eugene
On 29 апр, 17:07, Eugene Morozov <[EMAIL PROTECTED]> wrote: > Hello, > I'm new to django (using it only for two weeks and I was reading > django tutorial, documentation and book for the first week). > > I'm writing unit tests for my CMS similar to built-in flatpages CMS, > but with builtin i18n features and other things required for full- > fledged CMS. > > I cannot use standard django test client because it doesn't work with > middleware intercepting 404 errors (I didn't investigate why, because > I've thought that testing view manually would be easier). > Unfortunately, I was wrong. When I'm trying to test i18n features, > response.content returns non-ascii text *doubly* encoded in utf-8. > First invocation of response.content.decode('utf-8') returns unicode > object that contains utf-8 encoded original string. I can find some > tricky way to decode unicode object again using struct module or > something, but I don't understand why django encodes content twice. > And how test client gains access to template context. > > Will look at the sources meanwhile, but would be very grateful if > someone will explain. > Eugene --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---