Hi!
:)
I'm writing some tests requiring unicode values in URLs and also
uploaded via form submits. In the later case I'm getting the following
(client-side) error message
{{{#!py
Traceback (most recent call last):
[...]
File "/path/to/trac/trac/tests/functional/better_twill.py", line
169, in better_submit
b.submit(fieldname, formname)
File "/path/to/trac/trac/tests/functional/better_twill.py", line
165, in better_browser_submit
old_submit(fieldname)
File "/usr/lib/pymodules/python2.6/twill/browser.py", line 447, in submit
request = ctl._click(form, True, "", mechanize.Request)
File "/usr/lib/python2.6/dist-packages/ClientForm.py", line 2465, in _click
r = form._switch_click(return_type, request_class)
File "/usr/lib/python2.6/dist-packages/ClientForm.py", line 3390, in
_switch_click
req_data = self._request_data()
File "/usr/lib/python2.6/dist-packages/ClientForm.py", line 3364, in
_request_data
return (uri, urlencode(self._pairs()),
File "/usr/lib/python2.6/dist-packages/ClientForm.py", line 189, in urlencode
v = urllib.quote_plus(str(v))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in
position 2: ordinal not in range(128)
}}}
The root cause is that ClientForm (an indirect dependency introduced
by twill) converts unicode values using `str()` and such appraoch will
mostly fail.
I tried to work around this by encoding test with 'utf-8' . By doing
so the request is finally submitted but I get the following
(plain/text) HTTP response
{{{
Error TracError: ProgrammingError: You must not use 8-bit bytestrings
unless you use a text_factory that can interpret 8-bit bytestrings
(like text_factory = str). It is highly recommended that you instead
just switch your application to Unicode strings.
}}}
Therefore I ask ...
Q:
- What's the recommended approach to write test cases involving
unicode values in URLs and submit(s) ?
TIA
--
Regards,
Olemis - @olemislc
Apache⢠Bloodhound contributor
http://issues.apache.org/bloodhound
http://blood-hound.net
Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/
Featured article:
--
You received this message because you are subscribed to the Google Groups "Trac
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/trac-dev.
For more options, visit https://groups.google.com/groups/opt_out.