Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1556)

Unified Diff: Tools/appengine_testing/appengine_testing.py

Issue 465233002: Store alerts in sheriff-o-matic's memcache. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Feedback, use underscores in method names. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« Tools/GardeningServer/alerts.py ('K') | « Tools/appengine_testing/__init__.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Tools/appengine_testing/appengine_testing.py
diff --git a/Tools/appengine_testing/appengine_testing.py b/Tools/appengine_testing/appengine_testing.py
new file mode 100644
index 0000000000000000000000000000000000000000..6797a5ed6ba1faeef88ed33de94304442a7e0d54
--- /dev/null
+++ b/Tools/appengine_testing/appengine_testing.py
@@ -0,0 +1,54 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import imp
+import os
+import sys
+
+
+_gae_sdk_root_not_set_message = '''
+ You must set the environment variable GAE_SDK_ROOT to point to the
+ root of your google_appengine SDK installation.'''
+
+
+_webtest_not_installed_message = '''
+ Could not load webtest python module. You may need to:
+ sudo apt-get python-webtest
+'''
+
+
+def set_up():
+ """Sets up the environment for testing AppEngine services.
+
+ Checks, then configures the environment and sys.path to include
+ AppEngine libraries. Call this before importing test modules.
+
+ Raises:
+ AssertionError: the GAE_SDK_ROOT environment variable is not
+ set.
+ ImportError: webtest or AppEngine's wrapper_util could not be
+ imported.
+ """
+ assert 'GAE_SDK_ROOT' in os.environ, _gae_sdk_root_not_set_message
+ os.environ.setdefault('APPENGINE_RUNTIME', 'python27')
+
+ try:
+ wrapper_util = imp.load_module(
+ 'wrapper_util', *imp.find_module(
+ 'wrapper_util', [os.environ['GAE_SDK_ROOT']]))
+ except ImportError:
+ message = ('GAE_SDK_ROOT=%s does not look like the root of an '
+ 'AppEngine SDK installation') % os.environ['GAE_SDK_ROOT']
+ print >> sys.stderr, message
+ raise
+
+ extra_paths = wrapper_util.Paths(os.environ['GAE_SDK_ROOT']).v2_extra_paths
+ sys.path = extra_paths + sys.path
+
+ # Check that WebTest is installed. Handler integration tests use WebTest.
+ try:
+ import webtest
+ except ImportError:
+ print >> sys.stderr, _webtest_not_installed_message
+ raise
« Tools/GardeningServer/alerts.py ('K') | « Tools/appengine_testing/__init__.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698