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

Unified Diff: appengine_module/expect_tests_pretest.py

Issue 1866053002: [Findit] Move third-party libs to a sub directory and use appengine_config.py to add them at runtim… (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « appengine/findit/third_party/testing_utils ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine_module/expect_tests_pretest.py
diff --git a/appengine_module/expect_tests_pretest.py b/appengine_module/expect_tests_pretest.py
index 94a3e91232776b607d0dce51423df8759b6f6ecd..a18503f4dd04330ed7ac7d41c0586a998d0e2b8a 100644
--- a/appengine_module/expect_tests_pretest.py
+++ b/appengine_module/expect_tests_pretest.py
@@ -28,6 +28,26 @@ def _fix_sys_path_for_appengine(pretest_filename):
pretest_dev_appserver.fix_sys_path()
+def _load_appengine_config(pretest_filename):
+ app_dir = os.path.abspath(os.path.dirname(pretest_filename))
+ if not os.path.exists(os.path.join(app_dir, 'appengine_config.py')):
+ return
+
+ inserted = False
+ if app_dir not in sys.path:
+ sys.path.insert(0, app_dir)
+ inserted = True
+ import appengine_config # Unused Variable pylint: disable=W0612
+ if inserted:
+ sys.path.remove(app_dir)
+
+
# Using pretest_filename is magic, because it is available in the locals() of
# the script which execfiles this file.
_fix_sys_path_for_appengine(pretest_filename)
+
+# Load appengine_config from the appengine project to ensure that any changes to
+# configuration there are available to the tests (e.g. sys.path modifications,
+# namespaces, etc.). This is according to
+# https://cloud.google.com/appengine/docs/python/tools/localunittesting
+_load_appengine_config(pretest_filename)
« no previous file with comments | « appengine/findit/third_party/testing_utils ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698