本文整理汇总了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)