Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b928bb1

Browse files
author
Jon Wayne Parrott
committed
Adding nox configuration for the standard (non-gae) tests
1 parent 136e69d commit b928bb1

File tree

6 files changed

+88
-9
lines changed

6 files changed

+88
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ secrets.tar
1818
.cache
1919
junit.xml
2020
credentials.dat
21+
.nox

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ env:
1818
- GAE_ROOT=${HOME}/.cache/
1919
- secure: Orp9Et2TIwCG/Hf59aa0NUDF1pNcwcS4TFulXX175918cFREOzf/cNZNg+Ui585ZRFjbifZdc858tVuCVd8XlxQPXQgp7bwB7nXs3lby3LYg4+HD83Gaz7KOWxRLWVor6IVn8OxeCzwl6fJkdmffsTTO9csC4yZ7izHr+u7hiO4=
2020
before_install:
21+
- pip install --upgrade pip wheel virtualenv
2122
- openssl aes-256-cbc -k "$secrets_password" -in secrets.tar.enc -out secrets.tar -d
2223
- tar xvf secrets.tar
2324
install:
24-
- pip install tox coverage
25+
- pip install nox-automation coverage
2526
script:
2627
- source ${TRAVIS_BUILD_DIR}/testing/resources/test-env.sh
27-
- tox
28+
- nox --stop-on-first-error -s lint travis
29+
after_script:
2830
- coverage report

nox.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import fnmatch
2+
import os
3+
4+
import nox
5+
6+
REPO_TOOLS_REQ =\
7+
'git+https://github.com/GoogleCloudPlatform/python-repo-tools.git'
8+
9+
10+
def session_lint(session):
11+
session.install('flake8', 'flake8-import-order')
12+
session.run(
13+
'flake8', '--builtin=gettext', '--max-complexity=10',
14+
'--import-order-style=google',
15+
'--exclude',
16+
'container_engine/django_tutorial/polls/migrations/*,.nox,.cache,env',
17+
*(session.posargs or ['.']))
18+
19+
20+
def list_files(folder, pattern):
21+
for root, folders, files in os.walk(folder):
22+
for filename in files:
23+
if fnmatch.fnmatch(filename, pattern):
24+
yield os.path.join(root, filename)
25+
26+
27+
def session_reqcheck(session):
28+
session.install(REPO_TOOLS_REQ)
29+
30+
if 'update' in session.posargs:
31+
command = 'update-requirements'
32+
else:
33+
command = 'check-requirements'
34+
35+
for reqfile in list_files('.', 'requirements*.txt'):
36+
session.run('gcprepotools', command, reqfile)
37+
38+
39+
COMMON_PYTEST_ARGS = [
40+
'-x', '--no-success-flaky-report', '--cov', '--cov-config',
41+
'.coveragerc', '--cov-append', '--cov-report=']
42+
43+
SAMPLES = [
44+
'bigquery/api',
45+
'blog/introduction_to_data_models_in_cloud_datastore',
46+
'cloud_logging/api',
47+
'compute/api',
48+
'compute/autoscaler/demo',
49+
'datastore/api',
50+
'managed_vms/cloudsql',
51+
'managed_vms/datastore',
52+
'managed_vms/disk',
53+
'managed_vms/extending_runtime',
54+
'managed_vms/hello_world',
55+
'managed_vms/hello_world_compat',
56+
'managed_vms/memcache',
57+
'managed_vms/pubsub',
58+
'managed_vms/static_files',
59+
'managed_vms/storage',
60+
'monitoring/api',
61+
'storage/api',
62+
]
63+
64+
65+
@nox.parametrize('interpreter', ['python2.7', 'python3.4'])
66+
def session_tests(session, interpreter, extra_pytest_args=None):
67+
session.interpreter = interpreter
68+
session.install(REPO_TOOLS_REQ)
69+
session.install('-r', 'requirements-{}-dev.txt'.format(interpreter))
70+
71+
pytest_args = COMMON_PYTEST_ARGS + (extra_pytest_args or [])
72+
73+
for sample in (session.posargs or SAMPLES):
74+
session.run(
75+
'py.test', sample,
76+
*pytest_args,
77+
success_codes=[0, 5]) # Treat no test collected as success.
78+
79+
80+
def session_travis(session):
81+
"""On travis, just run with python3.4 and don't run slow or flaky tests."""
82+
session_tests(
83+
session, 'python3.4', extra_pytest_args=['-m not slow and not flaky'])
File renamed without changes.
File renamed without changes.

tox.ini

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,3 @@ whitelist_externals =
133133
bash
134134
find
135135
xargs
136-
137-
[flake8]
138-
exclude=container_engine/django_tutorial/polls/migrations/*
139-
140-
[pytest]
141-
addopts = -x --no-success-flaky-report --cov --cov-config .coveragerc --cov-append --cov-report=
142-

0 commit comments

Comments
 (0)