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

Unified Diff: appengine/swarming/swarming_bot/test_env_bot.py

Issue 2751863003: Ensure the packed version of protobuf is used on bot tests. (Closed)
Patch Set: With actual fixes Created 3 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/swarming/swarming_bot/test_env_bot.py
diff --git a/appengine/swarming/swarming_bot/test_env_bot.py b/appengine/swarming/swarming_bot/test_env_bot.py
index 25f7954d5d551a91e0fe443eab4a16bf3c3dfe37..74bf0a8412ccd6f57a6e7ab74a1a48570d29a620 100644
--- a/appengine/swarming/swarming_bot/test_env_bot.py
+++ b/appengine/swarming/swarming_bot/test_env_bot.py
@@ -36,8 +36,8 @@ def init_symlinks(root):
def setup_test_env():
"""Sets up the environment for bot tests."""
init_symlinks(BOT_DIR)
- client_tests = os.path.normpath(
- os.path.join(BOT_DIR, '..', '..', '..', 'client', 'tests'))
+ client = os.path.normpath(os.path.join(BOT_DIR, '..', '..', '..', 'client'))
+ client_tests = os.path.join(client, 'tests')
sys.path.insert(0, client_tests)
tp = os.path.join(BOT_DIR, 'third_party')
@@ -53,3 +53,19 @@ def setup_test_env():
# For python-rsa.
sys.path.insert(0, os.path.join(tp, 'rsa'))
sys.path.insert(0, os.path.join(tp, 'pyasn1'))
+
+ # Protobuf is now used in the bot itself.
+ # See fix_protobuf_package() in appengine/components/components/utils.py
+ # but until this code, the version under client is used.
+ if 'google' in sys.modules:
+ # It may be in lib/python2.7/site-packages/google, take not chance and flush
+ # it out.
+ del sys.modules['google']
+ # This should import client/third_party/google
+ import google
+ google_pkg = os.path.join(client, 'third_party', 'google')
+ if google_pkg not in google.__path__:
+ google.__path__.insert(0, google_pkg)
+ six_path = os.path.join(client, 'third_party', 'six')
+ if six_path not in sys.path:
+ sys.path.insert(0, six_path)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698