4

According to the Google AppEngine documentation, one should import memcache like this:

from google.appengine.api import memcache

I'm using a virtualenv and I'm creating some scripts to test a library I created for AppEngine. I am not trying to test a website, I am trying to test a specific library that uses memcache. Evidently, without using dev_appserver.py I get an ImportError: No module named google.appengine.api.

I had a look at the source of dev_appserver.py but first I'd like to know if there is a simpler solution that would not require rewriting PATH as Google does.

Thanks!

2 Answers 2

2

There is no simple solution, at the minimum you'll have to setup your Python paths. That's all the dev_appserver wrapper you linked to does. For testing code / libraries I usually write a simple wrapper that does basically the same thing as dev_appserver is doing.

In some cases you'll actually need to go a step further and initialize the stubs as well. If you follow through the dev_appserver code, you'll be able to see how this is done.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! I found this very interesting article: blairconrad.wordpress.com/2010/02/20/…
Cool, looks like a good resource! I've got similar setup code I use.
2

For testing purposes we always create a local checkout of the AppEngine library like this:

GAE_VERSION=1.6.2

resttest: dependencies lib/google_appengine/google/__init__.py
    sh -c "PYTHONPATH=lib/google_appengine/ python tests/resttest.py --hostname=$(TESTHOST) --credentials-user=$(CREDENTIALS_USER)"

lib/google_appengine/google/__init__.py:
    curl -s -O http://googleappengine.googlecode.com/files/google_appengine_$(GAE_VERSION).zip
    unzip -q google_appengine_$(GAE_VERSION).zip
    rm -Rf lib/google_appengine
    mv google_appengine lib/
    rm google_appengine_$(GAE_VERSION).zip

dependencies:
    git submodule update --init

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.