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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « appengine/findit/third_party/testing_utils ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # pylint: disable=undefined-variable 5 # pylint: disable=undefined-variable
6 6
7 # Crazy hack, because of appengine. 7 # Crazy hack, because of appengine.
8 import os 8 import os
9 import sys 9 import sys
10 10
(...skipping 10 matching lines...) Expand all
21 sys.path.remove(infra_base_dir) 21 sys.path.remove(infra_base_dir)
22 22
23 # Add the google_appengine directory. 23 # Add the google_appengine directory.
24 sys.path.insert(0, 24 sys.path.insert(0,
25 os.path.join(os.path.dirname(infra_base_dir), 'google_appengine')) 25 os.path.join(os.path.dirname(infra_base_dir), 'google_appengine'))
26 26
27 import dev_appserver as pretest_dev_appserver 27 import dev_appserver as pretest_dev_appserver
28 pretest_dev_appserver.fix_sys_path() 28 pretest_dev_appserver.fix_sys_path()
29 29
30 30
31 def _load_appengine_config(pretest_filename):
32 app_dir = os.path.abspath(os.path.dirname(pretest_filename))
33 if not os.path.exists(os.path.join(app_dir, 'appengine_config.py')):
34 return
35
36 inserted = False
37 if app_dir not in sys.path:
38 sys.path.insert(0, app_dir)
39 inserted = True
40 import appengine_config # Unused Variable pylint: disable=W0612
41 if inserted:
42 sys.path.remove(app_dir)
43
44
31 # Using pretest_filename is magic, because it is available in the locals() of 45 # Using pretest_filename is magic, because it is available in the locals() of
32 # the script which execfiles this file. 46 # the script which execfiles this file.
33 _fix_sys_path_for_appengine(pretest_filename) 47 _fix_sys_path_for_appengine(pretest_filename)
48
49 # Load appengine_config from the appengine project to ensure that any changes to
50 # configuration there are available to the tests (e.g. sys.path modifications,
51 # namespaces, etc.). This is according to
52 # https://cloud.google.com/appengine/docs/python/tools/localunittesting
53 _load_appengine_config(pretest_filename)
OLDNEW
« 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