Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"and" -> "or"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this check makes more sense in the caller, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meh.


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