Importing GAE libs when testing.

13 views
Skip to first unread message

Joops

unread,
Jul 10, 2011, 4:14:24 PM7/10/11
to Google App Engine
Hi all,

Sorry for what I consider a very simple question.

I want to check something I have done.

I wanted to do some test driven development for a specific part of my
project.

In order to run the tests I need to import the google libs (I am
running on MacOS)

I have put this at the top of my test script (Which I snaffled from
dev_appserver.py)

----

import os
import sys

DIR_PATH='/usr/local/google_appengine'
#SORT OUT THE IMPORTS FOR THE LIBS
EXTRA_PATHS = [
DIR_PATH,
os.path.join(DIR_PATH, 'lib', 'antlr3'),
os.path.join(DIR_PATH, 'lib', 'django_0_96'),
os.path.join(DIR_PATH, 'lib', 'fancy_urllib'),
os.path.join(DIR_PATH, 'lib', 'ipaddr'),

os.path.join(DIR_PATH, 'lib', 'webob'),
os.path.join(DIR_PATH, 'lib', 'yaml', 'lib'),
os.path.join(DIR_PATH, 'lib', 'simplejson'),
os.path.join(DIR_PATH, 'lib', 'graphy'),
]

sys.path = EXTRA_PATHS + sys.path

----

Now my test can use the google libs, and all is well.
Just wondered if there was a better way to achieve this?


Thanks ever so much

J

Tobias

unread,
Jul 10, 2011, 5:44:43 PM7/10/11
to google-a...@googlegroups.com
Hi Joops,

You might want to have a look a the docs on "Local Unit Testing for Python" [1] and especially on setting up a testing framework [2].

Cheers,
Tobias

Reply all
Reply to author
Forward
0 new messages