本文整理匯總了Python中dev_appserver.fix_sys_path方法的典型用法代碼示例。如果您正苦於以下問題:Python dev_appserver.fix_sys_path方法的具體用法?Python dev_appserver.fix_sys_path怎麽用?Python dev_appserver.fix_sys_path使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dev_appserver
的用法示例。
在下文中一共展示了dev_appserver.fix_sys_path方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: import dev_appserver [as 別名]
# 或者: from dev_appserver import fix_sys_path [as 別名]
def main(sdk_path, test_path, third_party_path=None):
sys.path.insert(0, sdk_path)
import dev_appserver
dev_appserver.fix_sys_path()
if third_party_path:
sys.path.insert(0, third_party_path)
try:
import appengine_config
(appengine_config)
except ImportError:
print "Note: unable to import appengine_config."
suite = unittest2.loader.TestLoader().discover(test_path,
pattern='*_test.py')
result = unittest2.TextTestRunner(verbosity=2).run(suite)
if len(result.errors) > 0 or len(result.failures) > 0:
sys.exit(1)
示例2: main
# 需要導入模塊: import dev_appserver [as 別名]
# 或者: from dev_appserver import fix_sys_path [as 別名]
def main(sdk_path, test_path, test_pattern):
# If the SDK path points to a Google Cloud SDK installation
# then we should alter it to point to the GAE platform location.
if os.path.exists(os.path.join(sdk_path, 'platform/google_appengine')):
sdk_path = os.path.join(sdk_path, 'platform/google_appengine')
# Make sure google.appengine.* modules are importable.
fixup_paths(sdk_path)
# Make sure all bundled third-party packages are available.
import dev_appserver
dev_appserver.fix_sys_path()
# Loading appengine_config from the current project ensures that any
# changes to configuration there are available to all tests (e.g.
# sys.path modifications, namespaces, etc.)
try:
import appengine_config
(appengine_config)
except ImportError:
print('Note: unable to import appengine_config.')
# Discover and run tests.
suite = unittest.loader.TestLoader().discover(test_path, test_pattern)
return unittest.TextTestRunner(verbosity=2).run(suite)
示例3: main
# 需要導入模塊: import dev_appserver [as 別名]
# 或者: from dev_appserver import fix_sys_path [as 別名]
def main(sdk_path, test_path, test_pattern):
# If the SDK path points to a Google Cloud SDK installation
# then we should alter it to point to the GAE platform location.
if os.path.exists(os.path.join(sdk_path, 'platform/google_appengine')):
sdk_path = os.path.join(sdk_path, 'platform/google_appengine')
# Make sure google.appengine.* modules are importable.
fixup_paths(sdk_path)
# Make sure all bundled third-party packages are available.
import dev_appserver
dev_appserver.fix_sys_path()
# Loading appengine_config from the current project ensures that any
# changes to configuration there are available to all tests (e.g.
# sys.path modifications, namespaces, etc.)
try:
import appengine_config
(appengine_config)
except ImportError:
print('Note: unable to import appengine_config.')
# Discover and run tests.
suite = unittest.loader.TestLoader().discover(test_path, test_pattern)
return unittest.TextTestRunner(verbosity=2).run(suite)
示例4: main
# 需要導入模塊: import dev_appserver [as 別名]
# 或者: from dev_appserver import fix_sys_path [as 別名]
def main(sdk_path, test_path):
os.chdir('backend')
sys.path.extend([sdk_path, '.', '../lib', '../testlib'])
import dev_appserver
dev_appserver.fix_sys_path()
suite = unittest.loader.TestLoader().discover(test_path)
if not unittest.TextTestRunner(verbosity=2).run(suite).wasSuccessful():
sys.exit(-1)
示例5: main
# 需要導入模塊: import dev_appserver [as 別名]
# 或者: from dev_appserver import fix_sys_path [as 別名]
def main(sdk_path, test_path):
sys.path.insert(0, sdk_path)
sys.path.insert(0, os.path.join(test_path, '../'))
sys.path.insert(0, os.path.join(test_path))
import dev_appserver
dev_appserver.fix_sys_path()
suite = unittest.loader.TestLoader().discover(test_path)
unittest.TextTestRunner(verbosity=10).run(suite)
示例6: set_appengine_imports
# 需要導入模塊: import dev_appserver [as 別名]
# 或者: from dev_appserver import fix_sys_path [as 別名]
def set_appengine_imports():
gae_path = os.getenv('GAE')
if gae_path is None:
return
sys.path.insert(0, gae_path)
sys.modules.pop('google', None)
import dev_appserver
dev_appserver.fix_sys_path()
if GOOGLE_PACKAGE_PATH is not None:
import google
GOOGLE_PACKAGE_PATH.update(google.__path__)
google.__path__ = list(GOOGLE_PACKAGE_PATH)
示例7: setup_gae_sdk
# 需要導入模塊: import dev_appserver [as 別名]
# 或者: from dev_appserver import fix_sys_path [as 別名]
def setup_gae_sdk(sdk_path):
"""Modifies sys.path and to be able to use Python portion of GAE SDK.
Once this is called, other functions from this module know where to find GAE
SDK and any AppEngine included Python module can be imported. The change is
global and permanent.
"""
global _GAE_SDK_PATH
if _GAE_SDK_PATH:
return
_GAE_SDK_PATH = sdk_path
sys.path.insert(0, sdk_path)
# Sadly, coverage may inject google.protobuf in the path. Forcibly expulse it.
if 'google' in sys.modules:
del sys.modules['google']
import dev_appserver
dev_appserver.fix_sys_path()
for i in sys.path[:]:
if 'jinja2-2.6' in i:
sys.path.remove(i)
# Make 'yaml' variable (defined on top of this module) point to loaded module.
global yaml
import yaml as yaml_module
yaml = yaml_module
示例8: path_setup
# 需要導入模塊: import dev_appserver [as 別名]
# 或者: from dev_appserver import fix_sys_path [as 別名]
def path_setup():
if 'GAE_SDK' in os.environ:
SDK_PATH = os.environ['GAE_SDK']
sys.path.insert(0, SDK_PATH)
import dev_appserver
dev_appserver.fix_sys_path()
sys.path.append(os.path.join(PROJECT_PATH, 'appengine'))
sys.path.append(os.path.join(PROJECT_PATH, 'apps'))
示例9: main
# 需要導入模塊: import dev_appserver [as 別名]
# 或者: from dev_appserver import fix_sys_path [as 別名]
def main(sdk_path, test_path, test_pattern):
# If the SDK path points to a Google Cloud SDK installation
# then we should alter it to point to the GAE platform location.
if os.path.exists(os.path.join(sdk_path, 'platform/google_appengine')):
sdk_path = os.path.join(sdk_path, 'platform/google_appengine')
# Make sure google.appengine.* modules are importable.
fixup_paths(sdk_path)
# Make sure all bundled third-party packages are available.
import dev_appserver
dev_appserver.fix_sys_path()
# Set test env vars.
os.environ['APPLICATION_ID'] = 'crmint-dev'
# Loading appengine_config from the current project ensures that any
# changes to configuration there are available to all tests (e.g.
# sys.path modifications, namespaces, etc.)
try:
import appengine_config
(appengine_config)
except ImportError:
print('Note: unable to import appengine_config.')
# Discover and run tests.
suite = unittest.loader.TestLoader().discover(test_path, test_pattern)
return unittest.TextTestRunner(verbosity=2).run(suite)