[Tutor] Missing in web.py and nosetests

李龑 eyeplum at gmail.com
Mon Aug 8 17:22:19 CEST 2011


Hi all,

I'm new in python and is learning about testing my little web.py app with
nosetests.

When the app is running in the web browser, it's ok. And the terminal
returns something like "127.0.0.1:51936 - - [08/Aug/2011 23:00:37] "HTTP/1.1
GET /hello" - 200 OK"

But when I'm trying to test the app with nosetests, it always goes wrong. As
I look into the Tracebacks, I guess this is caused by the templates I've
used in my app. But I'm not sure what should I do to make the nosetests
running right.

Hope some one can tell me what to do next.

Thanks.


PS: The Tracebacks looks like below:

> $ nosetests
> Traceback (most recent call last):
>   File "/Library/Python/2.7/site-packages/web/application.py", line 236, in
> process
>     return self.handle()
>   File "/Library/Python/2.7/site-packages/web/application.py", line 227, in
> handle
>     return self._delegate(fn, self.fvars, args)
>   File "/Library/Python/2.7/site-packages/web/application.py", line 409, in
> _delegate
>     return handle_class(cls)
>   File "/Library/Python/2.7/site-packages/web/application.py", line 384, in
> handle_class
>     return tocall(*args)
>   File "/Users/eyeplum/python/projects/gothonweb/bin/app.py", line 14, in
> GET
>     return render.hello_form()
>   File "/Library/Python/2.7/site-packages/web/template.py", line 1009, in
> __getattr__
>     t = self._template(name)
>   File "/Library/Python/2.7/site-packages/web/template.py", line 1006, in
> _template
>     return self._load_template(name)
>   File "/Library/Python/2.7/site-packages/web/template.py", line 993, in
> _load_template
>     raise AttributeError, "No template named " + name
> AttributeError: No template named hello_form
> F
> ======================================================================
> FAIL: tests.app_tests.test_index
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File
> "/Library/Python/2.7/site-packages/nose-1.1.1-py2.7.egg/nose/case.py", line
> 197, in runTest
>     self.test(*self.arg)
>   File "/Users/eyeplum/python/projects/gothonweb/tests/app_tests.py", line
> 12, in test_index
>     assert_response(resp)
>   File "/Users/eyeplum/python/projects/gothonweb/tests/tools.py", line 6,
> in assert_response
>     assert status in resp.status, "Expected response %r not in %r" %
> (status, resp.status)
> AssertionError: Expected response '200' not in '500 Internal Server Error'
> ----------------------------------------------------------------------
> Ran 1 test in 0.083s
> FAILED (failures=1)



And the book I'm learning: http://learnpythonthehardway.org/book/ex51.html


-- 

Li Yan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110808/5eaa2c27/attachment-0001.html>


More information about the Tutor mailing list