| OLD | NEW |
| 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 Loading... |
| 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) |
| OLD | NEW |