[TIP] Getting started writing DocTests for Web applications
Olemis Lang
olemis at gmail.com
Wed Feb 4 05:04:19 PST 2009
Hello everybody ...
On Mon, Jan 19, 2009 at 8:41 AM, Olemis Lang <olemis at gmail.com> wrote:
> On Mon, Jan 19, 2009 at 3:44 AM, Fran Boon <flavour at partyvibe.com> wrote:
>
>> Inspired by this post:
>> http://agiletesting.blogspot.com/2006/04/in-process-web-app-testing-with-twill.html
>>
> This is great ... I'll try to write a simple test like the one
> mentionned in this article, but using dutest ...
>
After reading Greg Gheorgiu's [1]_ post about using
twill + wsgi_intercept + doctest I've tried to follow the same steps
so as to test the same code snippet. This is what I've got :
{{{
>>> def simple_app(environ, start_response):
... status = '200 OK'
... response_headers = [('Content-type','text/plain')]
... start_response(status, response_headers)
... return ['Hello world!\n']
...
>>> import twill
>>> twill.add_wsgi_intercept('localhost', 8001, lambda: simple_app)
>>> from twill.commands import go
>>> go("http://localhost:8001/")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\program
files\python\2.5\lib\site-packages\twill-0.9-py2.5.egg\twill\commands.py",
line 112, in go
browser.go(url)
File "c:\program
files\python\2.5\lib\site-packages\twill-0.9-py2.5.egg\twill\browser.py",
line 122, in go
raise BrowserStateError("cannot go to '%s'" % (url,))
_mechanize_dist._mechanize.BrowserStateError: cannot go to
'http://localhost:8001/'
>>> twill.shell.main()
-= Welcome to twill! =-
current page: *empty page*
>> go http://localhost:8001/
ERROR: cannot go to 'http://localhost:8001/'
current page: *empty page*
}}}
Pls ... is there anybody out there ? ... What's wrong with it ? How
can I fix this ?
System Info
===========
OS : Windows XP
Python : 2.5.2
twill: 0.9
Installation was performed as follows ...
{{{
easy_install /home/myself/twill-0.9.tar.gz
}}}
... completed successfully ... I mean no error was displayed ...
I'll try to do the same thing now in Ubuntu Hardy ... wish me luck !
... I will let you know about the results ... ASAIC ... ;)
.. [1] In-process Web app testing with twill, wsgi_intercept and doctest
(http://agiletesting.blogspot.com/2006/04/in-process-web-app-testing-with-twill.html)
--
Regards,
Olemis.
Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/
More information about the testing-in-python
mailing list