<div dir="ltr">And also:<br> <br>Getting this in console when trying to generate report via HTMLTestRunner (it displayed text correctly when tried simple unittest.main)<br><td colspan='5' align='center'><a href="javascript:showOutput('pt1.1', 'test_create_account_to_check: Creating sample account for next test')">pass</a><br>
<script language="javascript" type="text/javascript">output_list['pt1.1'] = '!!! True\nÐ"омен \'foobar\' занÑÑ. РекомендованнÑе ÑвободнÑе доменÑ: ffoobar foobar.foobar foofoo fofo\n[]\n';</script><br>
</td><br></tr><br><br><br><br><div class="gmail_quote">On Thu, Jul 17, 2008 at 10:01 AM, Oleg Oltar <<a href="mailto:oltarasenko@gmail.com">oltarasenko@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div dir="ltr">beryl:~ oleg$ env<br>MANPATH=/usr/share/man:/usr/local/share/man:/usr/X11/man<br>TERM_PROGRAM=Apple_Terminal<br>TERM=xterm-color<br>SHELL=/bin/bash<br>TMPDIR=/var/folders/PC/PCtFE4gQGiqpQymiAScfnk+++TM/-Tmp-/<br>
Apple_PubSub_Socket_Render=/tmp/launch-UNXiC6/Render<br>TERM_PROGRAM_VERSION=237<br>USER=oleg<br>COMMAND_MODE=unix2003<br>SSH_AUTH_SOCK=/tmp/launch-hfpsIl/Listeners<br>__CF_USER_TEXT_ENCODING=0x1F6:0:0<br>PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin<br>
PWD=/Users/oleg<br>LANG=ru_RU.UTF-8<br>SHLVL=1<br>HOME=/Users/oleg<br>PYTHONPATH=:/Users/oleg/Documents/wishes_Test<br>LOGNAME=oleg<br>DISPLAY=/tmp/launch-1kgALC/:0<br>SECURITYSESSIONID=a206d0<div><div></div><div class="Wj3C7c">
<br><br><br><div class="gmail_quote">
On Thu, Jul 17, 2008 at 9:58 AM, Oleg Oltar <<a href="mailto:oltarasenko@gmail.com" target="_blank">oltarasenko@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div dir="ltr">See previous message (sent it few seconds ago)<div><div></div><div><br><br><div class="gmail_quote">On Thu, Jul 17, 2008 at 9:55 AM, Mark Tolonen <<a href="mailto:metolone%2Bgmane@gmail.com" target="_blank">metolone+gmane@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div bgcolor="#ffffff">
<div><font size="2">OK, your console is set to 'ascii' ('cp437' was my example and
is the<br>Windows console encoding). 'ascii' won't be able to display
Russian.<br>It shouldn't have displayed the "ИзвениÑ" characters
either.<br>Are you still running on the same terminal that display
those<br>characters? Can you change your terminals encoding preference via
an<br>environment variable?<br>--<br>Mark</font></div>
<blockquote style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Oleg Oltar" <<a href="mailto:oltarasenko@gmail.com" target="_blank">oltarasenko@gmail.com</a>> wrote in
message <a href="news:b4fc2ad80807162333k6badc3d3of87f402003a3a00a@mail.gmail.com" target="_blank">news:b4fc2ad80807162333k6badc3d3of87f402003a3a00a@mail.gmail.com</a>...</div><div><div></div><div>
<div dir="ltr"><br>And in case:<br># coding: utf-8<br><br>
<blockquote>import traceback <br>try:<br> raise
Exception(u'Зрегиться')<br>except Exception,e:<br> print
traceback.format_exc().decode('utf-8').encode('cp437',
'replace')<br></blockquote><br>Getting<br><br>beryl:~ oleg$ python
./wish/newaccount/reg.py<br>Traceback (most recent call last):<br> File
"./wish/newaccount/reg.py", line 5, in <module><br>
raise Exception(u'?????????')<br>Exception: <unprintable Exception
object><br><br><br><br>My console settings:<br><br>In [1]: import
sys<br><br>In [2]: sys.getdefaultencoding()<br>Out[2]: 'ascii'<br><br>In [3]:
sys.stdout.encoding<br>Out[3]: 'US-ASCII'<br><br><br>
<div class="gmail_quote">On Thu, Jul 17, 2008 at 9:30 AM, Oleg Oltar <<a href="mailto:oltarasenko@gmail.com" target="_blank">oltarasenko@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div dir="ltr">OK<br>the output:<br><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div># coding: utf-8<br><br>import traceback
<br>try:<br></div> raise Exception(u'Зрегиться')
<div><br>except Exception,e:<br> print
traceback.format_exc().decode('utf-8')</div></blockquote>
<div><br>
<div><br>>>> Traceback (most recent call
last):<br></div> File
"/var/folders/PC/PCtFE4gQGiqpQymiAScfnk+++TM/-Tmp-/py46506ECT", line 7, in
<module>
<div><br> print
traceback.format_exc().decode('utf-8')<br></div>UnicodeEncodeError: 'ascii'
codec can't encode characters in position 148-156: ordinal not in range(128)
<br><br><br><br></div>
<div>
<div></div>
<div><br>
<div class="gmail_quote">On Thu, Jul 17, 2008 at 8:13 AM, Mark Tolonen <<a href="mailto:metolone%2Bgmane@gmail.com" target="_blank">metolone+gmane@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div bgcolor="#ffffff">
<div><font size="2">The Exception is output in the encoding of the source
file. If the terminal you are displaying the exception on is in a
different encoding, it will be garbled. I'm not familiar with OS X's
terminal. Try running python and printing
sys.stdout.encoding.</font></div>
<div><font size="2"></font> </div>
<div><font size="2">Alternatively, wrap your code in a try/except handler
and translate the exception yourself.</font></div>
<div><font size="2"></font> </div>
<div><font size="2"> # coding: utf-8<br>
import traceback<br> try:<br></font><font size="2"> raise
Exception(u'Зарегистрироваться')<br> except
Exception,e:<br> print
traceback.format_exc().decode('utf-8')</font></div>
<div><font size="2"></font> </div>
<div><font size="2">The last line translates the utf-8 traceback into
Unicode. Printing Unicode will encode the output with the terminal's
decoding. If there are characters it can't display, you'll still get
an error, though. You can be more explicit however:</font></div>
<div><font size="2"></font> </div>
<div><font size="2"> print
traceback.format_exc().decode('utf-8').encode('cp437','replace')</font></div>
<div><font size="2"></font> </div>
<div><font size="2">In this case you'll get ? whenever a character can't be
represented in the selected encoding. cp437, for example, can't
display any russian characters, so for me (on Windows) I just get all
???????????. When I tried it with a character string that could be
displayed in cp437, it worked fine:</font></div>
<div><font size="2"></font> </div>
<div><font size="2">
<div> Traceback (most recent call
last):<br></div> File "<stdin>", line 1, in
<module><br> File "t4.py", line 4, in
<module><br> raise
Exception('MàΓ£ΦΘΩδ')<br> Exception:
MàΓ£ΦΘΩδ</font></div>
<div><font size="2"></font> </div>
<div><font size="2">Another option is to redirect the output to a file and
read the file with an editor that can display utf-8 (such as Notepad on
Windows).</font></div>
<div><font size="2"></font> </div>
<div><font size="2"> python testfile.py
2>error.txt #
this redirects stderr to a file.</font></div>
<div><font size="2"></font> </div>
<div><font size="2">Hope that helps,</font></div>
<div><font size="2">Mark</font></div>
<blockquote style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Oleg Oltar" <<a href="mailto:oltarasenko@gmail.com" target="_blank">oltarasenko@gmail.com</a>> wrote in message <a href="news:b4fc2ad80807162050s1de6b6aalc86203c7e1fe3df5@mail.gmail.com" target="_blank">news:b4fc2ad80807162050s1de6b6aalc86203c7e1fe3df5@mail.gmail.com</a>...</div>
<div>
<div></div>
<div>
<div dir="ltr">
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">The
code</blockquote>
<div> # -*- coding: utf-8
-*-<br>#!/usr/bin/python<br><br><br>"""<br><br>This test case check how
system works in the situation, when user tries to use already<br>used
username (domain)<br><br>We are creating two accounts with such
parameters:<br>1. Sex = Femle<br>2. Name1=Name2 = foobar%S <br>3. Pass1
= Name<br>4. Pass2 = Name<br>5. Email address1 = Email address2 =
<a href="mailto:Name@meta.ua" target="_blank">Name@meta.ua</a>
<br><br><br>In the test we use verification point - warning message
about incorrect input of domain name and the<br>sugestion
message<br><br>"""<br><br>from selenium import selenium<br>import
unittest, time, re<br>import HTMLTestRunner<br>import config<br>import
Creating_account_basic<br><br><br><br><br>class
Same_domain_name(unittest.TestCase):<br>
<br> def
setUp(self):
<br> <a href="http://self.name" target="_blank">self.name</a> =
"foobar"<br> self.email = <a href="http://self.name" target="_blank">self.name</a> + "@<a href="http://meta.ua" target="_blank">meta.ua</a>"
<br> self.verificationErrors =
[]<br> self.selenium =
selenium("localhost", 4444,config.browser,
config.link)<br>
self.selenium.start()<br><br> def
test_create_account_to_check(self):
<br> """Creating sample
account for next test"""<br>
sel = self.selenium<br>
sel.open("/")<br>
sel.click(u"link=Регистрация")<br>
sel.wait_for_page_to_load("70000")<br>
sel.click("id_gender_1")<br>
sel.type("id_first_name", <a href="http://self.name" target="_blank">self.name</a>)<br>
sel.type("id_last_name", <a href="http://self.name" target="_blank">self.name</a>)<br>
sel.type("id_email",
self.email)<br>
sel.type("id_username", <a href="http://self.name" target="_blank">self.name</a>)<br>
#sel.wait_for_condition(sel.is_element_present("check_username_block"),
70000)<br>
time.sleep(10)<br> print
"!!!",
sel.is_element_present("check_username_block")<br>
sel.type("id_password", <a href="http://self.name" target="_blank">self.name</a>)<br>
print
sel.get_text("check_username_block").decode('cp-1252')<br>
sel.type("id_password2", <a href="http://self.name" target="_blank">self.name</a>)<br>
sel.click(u"//input[@value='Зарегистрироваться']")<br>
sel.wait_for_page_to_load("70000")<br>
if config.debugMode is
True:<br>
time.sleep(5)<br><br><br> def
tearDown(self):<br>
self.selenium.stop()<br> print
self.verificationErrors<br>
self.assertEqual([], self.verificationErrors)<br><br>if __name__ ==
"__main__":<br> <br>
unittest.main()<br>
#HTMLTestRunner.main()<br> <br></div>
<div> </div><br>
<div class="gmail_quote">On Thu, Jul 17, 2008 at 6:47 AM, Oleg Oltar
<<a href="mailto:oltarasenko@gmail.com" target="_blank">oltarasenko@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div dir="ltr">In [1]: import sys<br><br>In [2]:
sys.getdefaultencoding()<br>Out[2]: 'ascii'<br><br>In [3]:
sys.stdout.encoding<br>Out[3]: 'US-ASCII'
<div>
<div></div>
<div><br><br>
<div class="gmail_quote">On Thu, Jul 17, 2008 at 6:29 AM, Oleg Oltar
<<a href="mailto:oltarasenko@gmail.com" target="_blank">oltarasenko@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div dir="ltr">Seems need help there. Start getting
<div><br><br>Traceback (most recent call last):<br></div> File
"./newaccount/Same_domain_name.py", line 56, in
test_create_account_to_check<br> print
sel.get_text("check_username_block")<br>UnicodeEncodeError: 'ascii'
codec can't encode characters in position 0-4: ordinal not in
range(128)<br><br><br>when trying to get the text of one of the
elements. <br><br>How to solve it?
<div>
<div></div>
<div><br><br>
<div class="gmail_quote">On Thu, Jul 17, 2008 at 5:11 AM, Oleg Oltar
<<a href="mailto:oltarasenko@gmail.com" target="_blank">oltarasenko@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div dir="ltr">OK,<br><br>I just run the program from terminal. OS:
OS X, IDLE = Emacs:).<br><br>Yep used the string "# -*- coding:
utf-8 -*-" to setup encoding....
<div>
<div></div>
<div><br><br>
<div class="gmail_quote">On Thu, Jul 17, 2008 at 4:14 AM, Kent
Johnson <<a href="mailto:kent37@tds.net" target="_blank">kent37@tds.net</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Another
possibility - do you have a coding declaration in your
source<br>file, something like<br># -*- coding: <encoding
name> -*-<br><br>If so, does the coding declaration match the
actual encoding of the file?<br><font color="#888888"><br>Kent<br></font>
<div>
<div></div>
<div><br>On Wed, Jul 16, 2008 at 5:11 PM, Kent Johnson <<a href="mailto:kent37@tds.net" target="_blank">kent37@tds.net</a>> wrote:<br>> On Wed, Jul
16, 2008 at 2:40 PM, Oleg Oltar <<a href="mailto:oltarasenko@gmail.com" target="_blank">oltarasenko@gmail.com</a>> wrote:<br>>>
Hi I am using unittest framework with
selenium.<br>>><br>>> When I tried this code (my
verification point)<br>>><br>>>
self.assertEqual(True, sel.is_text_present(u"Извените
пароли не<br>>> совпадают"), "System didn't give a correct
warning about the password<br>>>
misstype")<br>>><br>>>> Where u"Извените пароли
не совпадают" is russian = "Sorry passwords
aren't<br>>>> equal", and sel.is_text_present -
searches text string on the page<br>>><br>>> The
output I get in case of failure
was:<br>>><br>>><br>>> Traceback (most recent
call last):<br>>><br>>> File
"./newaccount/Password_matching.py", line 50, in<br>>>
test_passwordMatching<br>>>
self.assertEqual(True,
sel.is_text_present(u"Извените<br>>> пароли
не Ñ Ð¾Ð²Ð¿Ð°Ð´Ð°ÑŽÑ‚"), "System didn't give a
correct<br>>> warning about the password
misstype")<br>>><br>>> AssertionError: System didn't
give a correct warning about the password<br>>>
misstype<br>>><br>>> Is there any way to get normal
russian text instead of these strange D chars<br>>>
"Изве...."<br>><br>> I don't have the solution but
maybe I can give you a useful clue. The<br>> D characters are
most likely the utf-8 encoding of the Russian text,<br>> when
displayed as if it is latin-1. So something in the system
is<br>> converting the text to utf-8 and your console
probably has latin-1 or<br>> cp1252 encoding.<br>><br>>
Some details might help - how are you running the program -
console,<br>> IDLE...? What OS? What are the values of
sys.getdefaultencoding() and<br>>
sys.stdout.encoding?<br>><br>>
Kent<br>><br></div></div></blockquote></div><br></div></div></div></blockquote></div><br></div></div></div></blockquote></div><br></div></div></div></blockquote></div><br></div></div></div>
<p></p>
<hr>
<p></p>_______________________________________________<br>Tutor
maillist - <a href="mailto:Tutor@python.org" target="_blank">Tutor@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
</blockquote></div><br>_______________________________________________<br>Tutor
maillist - <a href="mailto:Tutor@python.org" target="_blank">Tutor@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br><br>
</blockquote></div><br></div></div></div></blockquote></div><br></div>
<p>
</p><hr>
<p></p>_______________________________________________<br>Tutor maillist
-
<a href="mailto:Tutor@python.org" target="_blank">Tutor@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br></div></div></blockquote>
</div>
<br>_______________________________________________<br>
Tutor maillist - <a href="mailto:Tutor@python.org" target="_blank">Tutor@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
<br></blockquote></div><br></div></div></div>
</blockquote></div><br></div></div></div>
</blockquote></div><br></div>