[Tutor] Missing in web.py and nosetests

Steven D'Aprano steve at pearwood.info
Mon Aug 8 21:02:26 CEST 2011


李龑 wrote:
> 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.


This is a forum for learning Python, not nose, or your web templating 
system. We can try to help, but you may have better luck on a dedicated 
nose forum, or on the main python-list at python.org mailing list (also 
available on Usenet comp.lang.python).


I don't actually use nose, so it is hard for me to interpret the 
tracebacks you give. My *guess* is that you are reporting one test 
*error* (a test that fails because your code is broken) plus one test 
*failure* (a test which just fails).


The first traceback you give seems to be an unexpected error:

>>   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

Do you actually have a template called "hello_form"? If not, then my 
*guess* is that this is an *error* (even though it prints F) because you 
don't actually have a template called hello_form.


The second traceback seems to be a failing test:

>> AssertionError: Expected response '200' not in '500 Internal Server Error'

Your test expects a 500 Internal Server Error, but you actually get a 
200 OK response. So your test is wrong: it fails for no good reason.


But I am not an expert on nose. I might be interpreting these tracebacks 
completely wrong.


Aside:

I can't find anything in the nose docs which explain how to read the 
test output except in the trivial case that all the tests pass.

http://packages.python.org/nose/index.html


-- 
Steven



More information about the Tutor mailing list