GAE的存根(用于单元测试)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了GAE的存根(用于单元测试)相关的知识,希望对你有一定的参考价值。
import sys import os APP_ID = u'aeweb_stub' AUTH_DOMAIN = 'gmail.com' from google.appengine.api import apiproxy_stub_map from google.appengine.api import datastore_file_stub from google.appengine.api import mail_stub from google.appengine.api import urlfetch_stub from google.appengine.api import user_service_stub from google.appengine.api.memcache import memcache_stub # Start with a fresh api proxy. apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap() # Use a fresh stub datastore. stub = datastore_file_stub.DatastoreFileStub(APP_ID, '/dev/null', '/dev/null') apiproxy_stub_map.apiproxy.RegisterStub('datastore_v3', stub) os.environ['APPLICATION_ID'] = APP_ID # Use a fresh stub UserService. apiproxy_stub_map.apiproxy.RegisterStub('user', user_service_stub.UserServiceStub()) os.environ['AUTH_DOMAIN'] = AUTH_DOMAIN os.environ['USER_EMAIL'] = LOGGED_IN_USER # Use a fresh urlfetch stub. apiproxy_stub_map.apiproxy.RegisterStub( 'urlfetch', urlfetch_stub.URLFetchServiceStub()) # Use a fresh mail stub. apiproxy_stub_map.apiproxy.RegisterStub( 'mail', mail_stub.MailServiceStub()) # Use a fresh memcache stub. apiproxy_stub_map.apiproxy.RegisterStub('memcache', memcache_stub.MemcacheServiceStub())
以上是关于GAE的存根(用于单元测试)的主要内容,如果未能解决你的问题,请参考以下文章