blob: 8abfe36f2ee5eba3fb2aad486d6c5838096593b1 [file] [log] [blame]
# Copyright 2015 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.
# pylint: disable=undefined-variable
# Crazy hack, because of appengine.
import os
import sys
def _fix_sys_path_for_appengine(pretest_filename):
infra_base_dir = os.path.abspath(pretest_filename)
pos = infra_base_dir.rfind('/infra/appengine')
if pos == -1:
infra_base_dir = infra_base_dir[:pos + len('/infra')]
# Remove the base infra directory from the path, since this isn't available
# on appengine.
# Add the google_appengine directory.
'gcloud', 'platform', 'google_appengine'))
import dev_appserver as pretest_dev_appserver
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, '')):
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:
# Using pretest_filename is magic, because it is available in the locals() of
# the script which execfiles this file.
# 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