Ahh found the problem I needed to write testparam.encode('utf-8')
On Dec 3, 4:20 pm, Kurt <[EMAIL PROTECTED]> wrote:
> Hi,
>
> testparam = u"testparam"
> response = self.app.post(url_for(controller='specialist',
> action='submitresult'), params={'testparam': testparam})
>
> works, while
>
> testparam = u"testpäräm"
> response = self.app.post(url_for(controller='specialist',
> action='submitresult'), params={'testparam': testparam})
>
> doesn't. Note the non-ascii characters in the unicode paramater value.
>
> I get the error:
>
> Traceback (most recent call last):
> File "D:\projects\SecondOpinion\SecondOpinion-dev\secondopinion\tests
> \function
> al\test_specialist.py", line 198, in test_submitresult
> 'testparam': testparam})
> File "c:\python25\lib\site-packages\paste-1.7.2-py2.5.egg\paste
> \fixture.py", l
> ine 262, in post
> expect_errors=expect_errors)
> File "c:\python25\lib\site-packages\paste-1.7.2-py2.5.egg\paste
> \fixture.py", l
> ine 222, in _gen_request
> params = urllib.urlencode(params)
> File "C:\Python25\lib\urllib.py", line 1250, in urlencode
> v = quote_plus(str(v))
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in
> position 6:
> ordinal not in range(128)
>
> This ONLY happens in this unit test, the same controller can handle
> non-ascii characters fine, when fed from a real web form.
>
> Any ideas how I can test the unicode characters from a unit test?
> (The file has # -*- coding: utf-8 -* at the beginning and removing
> that causes another error so that's not the problem.)
>
> Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---