Skip to content

Commit

Permalink
Unifiy app engine and python2.7 tests.
Browse files Browse the repository at this point in the history
Change-Id: Ie0df6747050035b2ef5f937951d5ff955073e6d4
  • Loading branch information
Jon Wayne Parrott committed Aug 17, 2016
1 parent b753fdf commit 96208a1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
15 changes: 15 additions & 0 deletions appengine/standard/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os

import six


# Import py.test hooks and fixtures for App Engine
from gcp.testing.appengine import (
login,
Expand All @@ -25,3 +30,13 @@
(pytest_runtest_call)
(run_tasks)
(testbed)


def pytest_ignore_collect(path, config):
"""Skip App Engine tests in python 3 and if no SDK is available."""
if 'appengine/standard' in str(path):
if six.PY3:
return True
if 'GAE_SDK_PATH' not in os.environ:
return True
return False
24 changes: 13 additions & 11 deletions nox.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,11 @@ def filter_samples(sample_dirs, changed_files):
def setup_appengine(session):
"""Installs the App Engine SDK."""
# Install the app engine sdk and setup import paths.
if session.interpreter.startswith('python3'):
return

gae_root = os.environ.get('GAE_ROOT', tempfile.gettempdir())
session.env['PYTHONPATH'] = os.path.join(gae_root, 'google_appengine')
session.env['GAE_SDK_PATH'] = os.path.join(gae_root, 'google_appengine')
session.run('gcprepotools', 'download-appengine-sdk', gae_root)

# Create a lib directory to prevent the GAE vendor library from
Expand All @@ -132,7 +135,7 @@ def setup_appengine(session):


def run_tests_in_sesssion(
session, interpreter, sample_directories, use_appengine=False,
session, interpreter, sample_directories, use_appengine=True,
skip_flaky=False, changed_only=False):
"""This is the main function for executing tests.
Expand Down Expand Up @@ -189,13 +192,12 @@ def session_tests(session, interpreter):
"""Runs tests for all non-gae standard samples."""
# session.posargs is any leftover arguments from the command line,
# which allows users to run a particular test instead of all of them.
if session.posargs:
sample_directories = session.posargs
elif sample_directories is None:
sample_directories = collect_sample_dirs(
'.', set('./appengine/standard'))
sample_directories = session.posargs
if not sample_directories:
sample_directories = collect_sample_dirs('.')

run_tests_in_sesssion(session, interpreter, sample_directories)
run_tests_in_sesssion(
session, interpreter, sample_directories, skip_flaky=True)


def session_gae(session):
Expand All @@ -212,12 +214,12 @@ def session_travis(session, subsession):
sample_directories = collect_sample_dirs(
'.', set('./appengine/standard'))
run_tests_in_sesssion(
session, 'python3.4', sample_directories, skip_flaky=True,
changed_only=True)
session, 'python3.4', sample_directories,
skip_flaky=True, changed_only=True)
else:
sample_directories = collect_sample_dirs('appengine/standard')
run_tests_in_sesssion(
session, 'python2.7', sample_directories, use_appengine=True,
session, 'python2.7', sample_directories,
skip_flaky=True, changed_only=True)


Expand Down

0 comments on commit 96208a1

Please sign in to comment.