开发者

Nose / Nosegae: Import problems

开发者 https://www.devze.com 2023-01-13 13:58 出处:网络
I have this problem and it\'s drivin\' me nuts! So I am developing my first real Google App Engine application and I always like to discover things while writing tests.

I have this problem and it's drivin' me nuts!

So I am developing my first real Google App Engine application and I always like to discover things while writing tests.

So I have the following setup:

I have a virtualenv with nose, nosegae, webtest and gaetestbed. It's called porksvr.

I activate my virtualenv like this:

source porksvr/bin/activate

To run nose I use the following command:

nosetests --with-gae --gae-lib-root /home/fs/gae

This gives me the following error

DEBUG: Access to module file denied: 
/home/fs/work/gaecode/porksvr/lib/python2.6/site-packages/webtest

So at first I thought "okay, nose is running the application in the 'context' of the dev_appserver so it doesn't know about webtest".

But to be sure I created a new directory and added a small GAE application. It's just 3 files:

-main.py

-app.yaml

-test_huh.py ( imports the webtest module. )

Now what really confused me is that this just works. I run the nosetests cmds and it's actually passing my tests.

So I started digging in my application to find out what could be different but I really hit a wall.

I first thought that it might be a permission problem since the error says 'access ...denied' but I couldn't really find anything special. Next I thought maybe it's because I created my application before the virtualenv but I couldn't really see how this can be a problem.

So if anybody has a clue why this happens I would be reall开发者_如何学编程y really grateful.


Nose-GAE has some documented issues when you're using virtualenv.

You might try using using nose's --without-sandbox flag.


Great so after hours of trying I actually just solved my problem right after asking this question.

What fixed it was to create the virtualenv with the following switch --no-site-packages. Apparently I had a copy of webtest in my system's Python that somehow gave problems with my virtualenv. I should have noticed it when I tried to pip install webtest in my virtualenv and it said it already existed.

Still not 100% sure why some apps worked and others didn't.

0

精彩评论

暂无评论...
验证码 换一张
取 消