[Tutor] Missing in web.py and nosetests

李龑 eyeplum at gmail.com
Tue Aug 9 08:27:01 CEST 2011

Thanks again.

I add "print os.getcwd()" inside* app.py* and *app_test.py(the nosetests
script)  *and find they are different.
In app.py, the working dir is the whole directory including all
subdirectories, but in app_test.py the working dir is the tests directory
I guess it's due to the working mechanism of the nosetests...

I also checked the permissions of those files, and they are all readable for
everyone :(

But I guess the problem is at the path of the template, the nosetests may
have a different way to know the template path. (But when I change the
pathname to be a absolute path, the nose goes wrong, and even the browser
can't see the webpage :(  ).

I also tried to add a* __init__.py* file into the templates directory, but
nothing different happens...(there is only 500 and AttributeError, "No
template named " + name)

the projects skeleton:

On Tue, Aug 9, 2011 at 8:02 AM, Steven D'Aprano <steve at pearwood.info> wrote:

> 李龑 wrote:
>> Thanks Steven.
>> Sorry for trying to discuss nose or templates here :(
> No need to be sorry, it isn't forbidden, but you may have more success
> asking help elsewhere.
>  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.
>> Yes, I have this template, and the app runs well when I manually testing
>> it
>> in a web browser. So I guess the promblem might be that the nose testing
>> system need some kind of special operations to make it know where the
>> template is(but actually I do have a *render =
>> web.template.render("**templates/", base="layout" *in my app which
>> declares
>> the place of the template).
> Then my guess is that the difference might be because you are calling the
> nose tests from a different working directory than the web browser sees. Can
> you get the app to display os.getcwd(), and then write a test that compares
> the working directory as seen by nose to the working directory as seen by
> the web app? Or change the template location to be an absolute pathname.
> Also check the permissions on the templates. Perhaps the template is
> readable by whatever user is running the web server, but not by whatever
> user is running the nose tests.
> All these suggestions are wild guesses, you understand.
> Good luck.
> --
> Steven
> ______________________________**_________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor>


李龑  |  Li Yan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110809/f433c219/attachment-0001.html>

More information about the Tutor mailing list