def main(): sys.path = extra_paths + sys.path os.environ['SERVER_SOFTWARE'] = 'Development via nose' os.environ['SERVER_NAME'] = 'Foo' os.environ['SERVER_PORT'] = '8080' os.environ['APPLICATION_ID'] = 'test-app-run' os.environ['USER_EMAIL'] = '*****@*****.**' os.environ['USER_ID'] = '42' os.environ['CURRENT_VERSION_ID'] = 'testing-version' os.environ['HTTP_HOST'] = 'some.testing.host.tld' setup_gae_services() import main as app_main import django.test.utils django.test.utils.setup_test_environment() plugins = [AppEngineDatastoreClearPlugin()] # For coverage if '--coverage' in sys.argv: from nose.plugins import cover plugin = cover.Coverage() from mox import stubout stubout_obj = stubout.StubOutForTesting() stubout_obj.SmartSet(plugin, 'begin', begin) plugins.append(plugin) args = ['--with-coverage', '--cover-package=soc.', '--cover-erase', '--cover-html', '--cover-html-dir=coverageResults'] sys.argv.remove('--coverage') sys.argv += args else: load_melange() # For multiprocess will_multiprocess = False for arg in sys.argv[1:]: if '--processes' in arg: will_multiprocess = True break if will_multiprocess: from mox import stubout from nose.plugins import multiprocess stubout_obj = stubout.StubOutForTesting() stubout_obj.SmartSet(multiprocess, '__runner', multiprocess_runner) # The default --process-timeout (10s) is too short sys.argv += ['--process-timeout=300'] # Ignore functional and old_app tests args = ['--exclude=functional', '--exclude=^old_app$'] sys.argv += args nose.main(addplugins=plugins)
def main(): sys.path = extra_paths + sys.path os.environ['SERVER_SOFTWARE'] = 'Development via nose' os.environ['SERVER_NAME'] = 'Foo' os.environ['SERVER_PORT'] = '8080' os.environ['APPLICATION_ID'] = 'test-app-run' os.environ['USER_EMAIL'] = '*****@*****.**' os.environ['USER_ID'] = '42' os.environ['CURRENT_VERSION_ID'] = 'testing-version' os.environ['HTTP_HOST'] = 'some.testing.host.tld' setup_gae_services() import main as app_main import django.test.utils django.test.utils.setup_test_environment() plugins = [AppEngineDatastoreClearPlugin()] # For coverage if '--coverage' in sys.argv: from nose.plugins import cover plugin = cover.Coverage() from mox import stubout stubout_obj = stubout.StubOutForTesting() stubout_obj.SmartSet(plugin, 'begin', begin) plugins.append(plugin) args = [ '--with-coverage', '--cover-package=soc.', '--cover-erase', '--cover-html', '--cover-html-dir=coverageResults' ] sys.argv.remove('--coverage') sys.argv += args else: load_melange() # For multiprocess will_multiprocess = False for arg in sys.argv[1:]: if '--processes' in arg: will_multiprocess = True break if will_multiprocess: from mox import stubout from nose.plugins import multiprocess stubout_obj = stubout.StubOutForTesting() stubout_obj.SmartSet(multiprocess, '__runner', multiprocess_runner) # The default --process-timeout (10s) is too short sys.argv += ['--process-timeout=300'] # Ignore functional and old_app tests args = ['--exclude=functional', '--exclude=^old_app$'] sys.argv += args nose.main(addplugins=plugins)
def main(): sys.path = extra_paths + sys.path os.environ['SERVER_SOFTWARE'] = 'Development via nose' os.environ['SERVER_NAME'] = 'Foo' os.environ['SERVER_PORT'] = '8080' os.environ['APPLICATION_ID'] = 'test-app-run' os.environ['USER_EMAIL'] = '*****@*****.**' os.environ['CURRENT_VERSION_ID'] = 'testing-version' os.environ['HTTP_HOST'] = 'some.testing.host.tld' import main as app_main 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 user_service_stub from google.appengine.api import urlfetch_stub from google.appengine.api.memcache import memcache_stub apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap() apiproxy_stub_map.apiproxy.RegisterStub( 'urlfetch', urlfetch_stub.URLFetchServiceStub()) apiproxy_stub_map.apiproxy.RegisterStub( 'user', user_service_stub.UserServiceStub()) apiproxy_stub_map.apiproxy.RegisterStub( 'datastore', datastore_file_stub.DatastoreFileStub('test-app-run', None, None)) apiproxy_stub_map.apiproxy.RegisterStub( 'memcache', memcache_stub.MemcacheServiceStub()) apiproxy_stub_map.apiproxy.RegisterStub('mail', mail_stub.MailServiceStub()) import django.test.utils django.test.utils.setup_test_environment() # register a core for the test modules to use from soc.modules import callback from soc.modules import core callback.registerCore(core.Core()) callback.getCore().registerModuleCallbacks() plugins = [AppEngineDatastoreClearPlugin()] if '--coverage' in sys.argv: from nose.plugins import cover plugin = cover.Coverage() plugins.append(plugin) args = [ '--with-coverage', '--cover-package=soc', '--cover-erase', '--cover-html', '--cover-html-dir=coverageResults' ] sys.argv.remove('--coverage') sys.argv += args nose.main(plugins=plugins)
def run_pyunit_tests(): sys.path = extra_paths + sys.path os.environ['SERVER_SOFTWARE'] = 'Development via nose' os.environ['SERVER_NAME'] = 'Foo' os.environ['SERVER_PORT'] = '8080' os.environ['APPLICATION_ID'] = 'test-app-run' os.environ['USER_EMAIL'] = '*****@*****.**' os.environ['USER_ID'] = '42' os.environ['USER_IS_ADMIN'] = '0' os.environ['CURRENT_VERSION_ID'] = 'testing-version' os.environ['HTTP_HOST'] = 'some.testing.host.tld' os.environ['APPENGINE_RUNTIME'] = 'python27' setup_gae_services() # settings cannot be imported at module level, as it requires all # environmental variables to be already set import settings settings.MIDDLEWARE_CLASSES = list( settings.MIDDLEWARE_CLASSES) + ['test_utils.FakeBlobstoreMiddleware'] import main as app_main import django.test.utils django.test.utils.setup_test_environment() plugins = [ AppEngineDatastoreClearPlugin(), AppEngineMemcacheClearPlugin(), DefaultUserSignInPlugin() ] # For coverage if '--coverage' in sys.argv: from nose.plugins import cover plugin = cover.Coverage() plugin._orig_begin = plugin.begin stubout_obj = stubout.StubOutForTesting() stubout_obj.SmartSet(plugin, 'begin', begin) plugins.append(plugin) args = [ '--with-coverage', '--cover-package=soc.,melange.,summerofcode.,codein.', '--cover-erase', '--cover-html', '--cover-html-dir=reports/py_coverage' ] sys.argv.remove('--coverage') sys.argv += args else: load_melange() # For multiprocess will_multiprocess = False for arg in sys.argv[1:]: if '--processes' in arg: will_multiprocess = True break if will_multiprocess: from nose.plugins import multiprocess stubout_obj = stubout.StubOutForTesting() stubout_obj.SmartSet(multiprocess, '__runner', multiprocess_runner) stubout_obj.SmartSet(multiprocess.MultiProcessTestRunner, 'checkCanSplit', staticmethod(checkCanSplit)) # The default --process-timeout (10s) is too short sys.argv += ['--process-timeout=300'] # Ignore functional and old_app tests args = ['--exclude=functional', '--exclude=^old_app$'] sys.argv += args nose.run(addplugins=plugins)
def main(): sys.path = extra_paths + sys.path os.environ['SERVER_SOFTWARE'] = 'Development via nose' os.environ['SERVER_NAME'] = 'Foo' os.environ['SERVER_PORT'] = '8080' os.environ['APPLICATION_ID'] = 'test-app-run' os.environ['USER_EMAIL'] = '*****@*****.**' os.environ['USER_ID'] = '42' os.environ['CURRENT_VERSION_ID'] = 'testing-version' os.environ['HTTP_HOST'] = 'some.testing.host.tld' import main as app_main 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 user_service_stub from google.appengine.api import urlfetch_stub from google.appengine.api.memcache import memcache_stub from google.appengine.api.taskqueue import taskqueue_stub apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap() apiproxy_stub_map.apiproxy.RegisterStub('urlfetch', urlfetch_stub.URLFetchServiceStub()) apiproxy_stub_map.apiproxy.RegisterStub('user', user_service_stub.UserServiceStub()) apiproxy_stub_map.apiproxy.RegisterStub('datastore', datastore_file_stub.DatastoreFileStub('test-app-run', None, None)) apiproxy_stub_map.apiproxy.RegisterStub('memcache', memcache_stub.MemcacheServiceStub()) apiproxy_stub_map.apiproxy.RegisterStub('mail', mail_stub.MailServiceStub()) yaml_location = os.path.join(HERE, 'app') apiproxy_stub_map.apiproxy.RegisterStub( 'taskqueue', taskqueue_stub.TaskQueueServiceStub(root_path=yaml_location)) import django.test.utils django.test.utils.setup_test_environment() plugins = [AppEngineDatastoreClearPlugin()] if '--coverage' in sys.argv: from nose.plugins import cover plugin = cover.Coverage() from mox import stubout stubout_obj = stubout.StubOutForTesting() stubout_obj.SmartSet(plugin, 'begin', begin) plugins.append(plugin) args = ['--with-coverage', '--cover-package=soc.', '--cover-erase', '--cover-html', '--cover-html-dir=coverageResults'] sys.argv.remove('--coverage') sys.argv += args else: load_melange() # Ignore functional, views and tasks tests temporarily args = ['--exclude=functional', '--exclude=^views$', '--exclude=^tasks$'] sys.argv += args nose.main(addplugins=plugins)
def run_pyunit_tests(): sys.path = extra_paths + sys.path os.environ['SERVER_SOFTWARE'] = 'Development via nose' os.environ['SERVER_NAME'] = 'Foo' os.environ['SERVER_PORT'] = '8080' os.environ['APPLICATION_ID'] = 'test-app-run' os.environ['USER_EMAIL'] = '*****@*****.**' os.environ['USER_ID'] = '42' os.environ['USER_IS_ADMIN'] = '0' os.environ['CURRENT_VERSION_ID'] = 'testing-version' os.environ['HTTP_HOST'] = 'some.testing.host.tld' os.environ['APPENGINE_RUNTIME'] = 'python27' setup_gae_services() # settings cannot be imported at module level, as it requires all # environmental variables to be already set import settings settings.MIDDLEWARE_CLASSES = list(settings.MIDDLEWARE_CLASSES) + [ 'test_utils.FakeBlobstoreMiddleware'] import main as app_main import django.test.utils django.test.utils.setup_test_environment() plugins = [ AppEngineDatastoreClearPlugin(), AppEngineMemcacheClearPlugin(), DefaultUserSignInPlugin() ] # For coverage if '--coverage' in sys.argv: from nose.plugins import cover plugin = cover.Coverage() plugin._orig_begin = plugin.begin stubout_obj = stubout.StubOutForTesting() stubout_obj.SmartSet(plugin, 'begin', begin) plugins.append(plugin) args = ['--with-coverage', '--cover-package=soc.,melange.,summerofcode.,codein.', '--cover-erase', '--cover-html', '--cover-html-dir=reports/py_coverage'] sys.argv.remove('--coverage') sys.argv += args else: load_melange() # For multiprocess will_multiprocess = False for arg in sys.argv[1:]: if '--processes' in arg: will_multiprocess = True break if will_multiprocess: from nose.plugins import multiprocess stubout_obj = stubout.StubOutForTesting() stubout_obj.SmartSet(multiprocess, '__runner', multiprocess_runner) stubout_obj.SmartSet(multiprocess.MultiProcessTestRunner, 'checkCanSplit', staticmethod(checkCanSplit)) # The default --process-timeout (10s) is too short sys.argv += ['--process-timeout=300'] # Ignore functional and old_app tests args = ['--exclude=functional', '--exclude=^old_app$'] sys.argv += args nose.run(addplugins=plugins)
def main(): sys.path = extra_paths + sys.path os.environ['SERVER_SOFTWARE'] = 'Development via nose' os.environ['SERVER_NAME'] = 'Foo' os.environ['SERVER_PORT'] = '8080' os.environ['APPLICATION_ID'] = 'test-app-run' os.environ['USER_EMAIL'] = '*****@*****.**' os.environ['USER_ID'] = '42' os.environ['CURRENT_VERSION_ID'] = 'testing-version' os.environ['HTTP_HOST'] = 'some.testing.host.tld' import main as app_main 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 user_service_stub from google.appengine.api import urlfetch_stub from google.appengine.api.memcache import memcache_stub from google.appengine.api.taskqueue import taskqueue_stub apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap() apiproxy_stub_map.apiproxy.RegisterStub( 'urlfetch', urlfetch_stub.URLFetchServiceStub()) apiproxy_stub_map.apiproxy.RegisterStub( 'user', user_service_stub.UserServiceStub()) apiproxy_stub_map.apiproxy.RegisterStub( 'datastore', datastore_file_stub.DatastoreFileStub('test-app-run', None, None)) apiproxy_stub_map.apiproxy.RegisterStub( 'memcache', memcache_stub.MemcacheServiceStub()) apiproxy_stub_map.apiproxy.RegisterStub('mail', mail_stub.MailServiceStub()) yaml_location = os.path.join(HERE, 'app') apiproxy_stub_map.apiproxy.RegisterStub( 'taskqueue', taskqueue_stub.TaskQueueServiceStub(root_path=yaml_location)) import django.test.utils django.test.utils.setup_test_environment() plugins = [AppEngineDatastoreClearPlugin()] if '--coverage' in sys.argv: from nose.plugins import cover plugin = cover.Coverage() from mox import stubout stubout_obj = stubout.StubOutForTesting() stubout_obj.SmartSet(plugin, 'begin', begin) plugins.append(plugin) args = [ '--with-coverage', '--cover-package=soc.', '--cover-erase', '--cover-html', '--cover-html-dir=coverageResults' ] sys.argv.remove('--coverage') sys.argv += args else: load_melange() # Ignore functional, views and tasks tests temporarily args = ['--exclude=functional', '--exclude=^views$', '--exclude=^tasks$'] sys.argv += args nose.main(addplugins=plugins)