Created
December 8, 2011 23:08
-
-
Save pamelafox/1449158 to your computer and use it in GitHub Desktop.
Python Flask App Engine Unit Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
import sys | |
import os | |
import logging | |
# locate app-engine SDK | |
AE_PATH = "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/" | |
# path to app code | |
APP_PATH = os.path.abspath(".") | |
# load the AE paths (as stolen from dev_appserver.py) | |
EXTRA_PATHS = [ | |
APP_PATH, | |
AE_PATH, | |
os.path.join(AE_PATH, 'lib', 'antlr3'), | |
os.path.join(AE_PATH, 'lib', 'django'), | |
os.path.join(AE_PATH, 'lib', 'ipaddr'), | |
os.path.join(AE_PATH, 'lib', 'webob'), | |
os.path.join(AE_PATH, 'lib', 'yaml', 'lib'), | |
os.path.join(AE_PATH, 'lib', 'fancy_urllib'), # issue[1] | |
] | |
sys.path = EXTRA_PATHS + sys.path | |
package_dir = APP_PATH + '/packages' | |
# Allow unzipped packages to be imported | |
# from packages folder | |
sys.path.insert(0, package_dir) | |
# Append zip archives to path for zipimport | |
for filename in os.listdir(package_dir): | |
if filename.endswith((".zip", ".egg")): | |
sys.path.insert(0, "%s/%s" % (package_dir, filename)) | |
from google.appengine.ext import testbed | |
import application | |
import test_defaults |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment