Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def main(sdk_path, test_path):
sys.path.insert(0, sdk_path)
import dev_appserver
dev_appserver.fix_sys_path()
suite = unittest2.loader.TestLoader().discover(test_path)
test_result = unittest2.TextTestRunner(verbosity=2, buffer=True, failfast=True).run(suite)
if not test_result.wasSuccessful():
sys.exit(1)
def main(sdk_path, test_paths):
if 'lib' not in sys.path:
sys.path.insert(0, 'lib')
sys.path.insert(0, sdk_path)
import dev_appserver
dev_appserver.fix_sys_path()
suites = unittest2.TestSuite()
for test_path in test_paths:
suite = None
# tests/ directory
if os.path.isdir(test_path):
suite = unittest2.loader.TestLoader().discover(test_path)
# test_file.py
elif os.path.isfile(test_path):
test_path, test_file = test_path.rsplit(os.path.sep, 1)
suite = unittest2.loader.TestLoader().discover(test_path, test_file)
# tests.module.TestCase
elif '/' not in test_path and '.' in test_path:
suite = unittest2.loader.TestLoader().loadTestsFromName(test_path)
if suite is not None:
suites.addTest(suite)
unittest2.TextTestRunner(verbosity=2).run(suites)
import dev_appserver
dev_appserver.fix_sys_path()
suites = unittest2.TestSuite()
for test_path in test_paths:
suite = None
# tests/ directory
if os.path.isdir(test_path):
suite = unittest2.loader.TestLoader().discover(test_path)
# test_file.py
elif os.path.isfile(test_path):
test_path, test_file = test_path.rsplit(os.path.sep, 1)
suite = unittest2.loader.TestLoader().discover(test_path, test_file)
# tests.module.TestCase
elif '/' not in test_path and '.' in test_path:
suite = unittest2.loader.TestLoader().loadTestsFromName(test_path)
if suite is not None:
suites.addTest(suite)
unittest2.TextTestRunner(verbosity=2).run(suites)
sys.path.insert(0, 'lib')
sys.path.insert(0, sdk_path)
import dev_appserver
dev_appserver.fix_sys_path()
suites = unittest2.TestSuite()
for test_path in test_paths:
suite = None
# tests/ directory
if os.path.isdir(test_path):
suite = unittest2.loader.TestLoader().discover(test_path)
# test_file.py
elif os.path.isfile(test_path):
test_path, test_file = test_path.rsplit(os.path.sep, 1)
suite = unittest2.loader.TestLoader().discover(test_path, test_file)
# tests.module.TestCase
elif '/' not in test_path and '.' in test_path:
suite = unittest2.loader.TestLoader().loadTestsFromName(test_path)
if suite is not None:
suites.addTest(suite)
unittest2.TextTestRunner(verbosity=2).run(suites)
def main(sdk_path, test_pattern):
logging.disable(logging.WARNING)
start_time = time.time()
os.environ['IS_TBA_TEST'] = "true"
sys.path.insert(0, sdk_path)
import dev_appserver
dev_appserver.fix_sys_path()
# Set up custom django template filters
from google.appengine.ext.webapp import template
template.register_template_library('common.my_filters')
suites = unittest2.loader.TestLoader().discover("tests", test_pattern)
fail = False
total_tests_run = 0
if MULTITHREAD:
proc_lock = multiprocessing.Lock()
fail_count = multiprocessing.Value('i', 0)
total_run = multiprocessing.Value('i', 0)
pool = multiprocessing.Pool(MAX_JOBS, initializer=proc_init, initargs=(proc_lock, fail_count, total_run,))
pool.map(run_suite, suites)
pool.close()
pool.join()
fail = fail_count.value > 0
total_tests_run = total_run.value
else:
result_queue = multiprocessing.Queue()
sys.path.insert(0, sdk_path)
import dev_appserver
dev_appserver.fix_sys_path()
# Set up datastore so we can test on meaningful data.
t = testbed.Testbed()
t.setup_env(True, application_id='dev~openmobiledata')
t.activate()
t.init_datastore_v3_stub(True, TEST_DATASTORE, False)
t.init_memcache_stub()
# Get correct Django version.
from google.appengine.dist import use_library
use_library('django', '1.2')
suite = unittest2.loader.TestLoader().discover(test_path,
pattern='*_test.py')
unittest2.TextTestRunner(verbosity=2).run(suite)
t.deactivate()
"""Register search service"""
from google.appengine.api import apiproxy_stub_map
from google.appengine.api.search import simple_search_stub
apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()
apiproxy_stub_map.apiproxy.RegisterStub('search',
simple_search_stub.SearchServiceStub())
"""Register memcache service"""
from google.appengine.api.memcache import memcache_stub
apiproxy_stub_map.apiproxy.RegisterStub('memcache',
memcache_stub.MemcacheServiceStub())
"""Register user service"""
from google.appengine.api import user_service_stub
apiproxy_stub_map.apiproxy.RegisterStub('user',
user_service_stub.UserServiceStub())
suite = unittest2.loader.TestLoader().discover(test_path)
unittest2.TextTestRunner(verbosity=2).run(suite)
def main(gae_lib_root, start_dir):
"""Try to load Google App Engine SDK and then to run any tests found with
unittest2 discovery feature.
If a test fail, it will exit with a status code of 1.
"""
setup_gae(gae_lib_root)
suite = unittest.loader.TestLoader().discover(start_dir)
results = unittest.TextTestRunner(verbosity=2, buffer=True).run(suite)
if not results.wasSuccessful():
sys.exit(1)