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

Unified Diff: appengine/path_mangler_hack.py

Issue 499103002: Make test_results deployable again. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: merge to ToT 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
« no previous file with comments | « appengine/chromium_cq_status/tests/utils_test.py ('k') | appengine/test_results/__init__.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/path_mangler_hack.py
diff --git a/appengine/path_mangler_hack.py b/appengine/path_mangler_hack.py
new file mode 100644
index 0000000000000000000000000000000000000000..147b794bbf459316bf771213cd8ec13fd88a02f1
--- /dev/null
+++ b/appengine/path_mangler_hack.py
@@ -0,0 +1,34 @@
+# 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 sys
+
+# App Engine source file imports must be relative to their app's root.
+# Provide a way to mangle sys.path, but not leave it littered with junk.
+
+# TODO(ojan): This is a stopgap. Come up with a more general solution.
+
+# pylint: disable=W0702
+
+class PathMangler: # pragma: no cover
+ def __init__(self, root):
+ self.app_root = root
+
+ def __enter__(self):
+ sys.path.append(self.app_root)
+
+ try:
+ import model
+ reload(model)
+ except:
+ pass
+
+ try:
+ import handlers
+ reload(handlers)
+ except:
+ pass
+
+ def __exit__(self, etype, value, etraceback):
+ sys.path.remove(self.app_root)
« no previous file with comments | « appengine/chromium_cq_status/tests/utils_test.py ('k') | appengine/test_results/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698