[Tutor] Unittest

Oleg Oltar oltarasenko at gmail.com
Thu Jul 17 05:29:21 CEST 2008


Seems need help there. Start getting

Traceback (most recent call last):
  File "./newaccount/Same_domain_name.py", line 56, in
test_create_account_to_check
    print sel.get_text("check_username_block")
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4:
ordinal not in range(128)


when trying to get the text of one of the elements.

How to solve it?

On Thu, Jul 17, 2008 at 5:11 AM, Oleg Oltar <oltarasenko at gmail.com> wrote:

> OK,
>
> I just run the program from terminal. OS: OS X, IDLE = Emacs:).
>
> Yep used the string "# -*- coding: utf-8 -*-" to setup encoding....
>
>
> On Thu, Jul 17, 2008 at 4:14 AM, Kent Johnson <kent37 at tds.net> wrote:
>
>> Another possibility - do you have a coding declaration in your source
>> file, something like
>> # -*- coding: <encoding name> -*-
>>
>> If so, does the coding declaration match the actual encoding of the file?
>>
>> Kent
>>
>> On Wed, Jul 16, 2008 at 5:11 PM, Kent Johnson <kent37 at tds.net> wrote:
>> > On Wed, Jul 16, 2008 at 2:40 PM, Oleg Oltar <oltarasenko at gmail.com>
>> wrote:
>> >> Hi I am using unittest framework with selenium.
>> >>
>> >> When I tried this code (my verification point)
>> >>
>> >>         self.assertEqual(True, sel.is_text_present(u"Извените пароли не
>> >> совпадают"), "System didn't give a correct warning about the password
>> >> misstype")
>> >>
>> >>> Where u"Извените пароли не совпадают" is russian = "Sorry passwords
>> aren't
>> >>> equal", and sel.is_text_present - searches text string on the page
>> >>
>> >> The output I get in case of failure was:
>> >>
>> >>
>> >> Traceback (most recent call last):
>> >>
>> >>   File "./newaccount/Password_matching.py", line 50, in
>> >> test_passwordMatching
>> >>     self.assertEqual(True, sel.is_text_present(u"Извените
>> >> пароли не Ñ Ð¾Ð²Ð¿Ð°Ð´Ð°ÑŽÑ‚"), "System didn't give a correct
>> >> warning about the password misstype")
>> >>
>> >> AssertionError: System didn't give a correct warning about the password
>> >> misstype
>> >>
>> >> Is there any way to get normal russian text instead of these strange D
>> chars
>> >> "Изве...."
>> >
>> > I don't have the solution but maybe I can give you a useful clue. The
>> > D characters are most likely the utf-8 encoding of the Russian text,
>> > when displayed as if it is latin-1. So something in the system is
>> > converting the text to utf-8 and your console probably has latin-1 or
>> > cp1252 encoding.
>> >
>> > Some details might help - how are you running the program - console,
>> > IDLE...? What OS? What are the values of sys.getdefaultencoding() and
>> > sys.stdout.encoding?
>> >
>> > Kent
>> >
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080717/76ec9aab/attachment-0001.htm>


More information about the Tutor mailing list