Skip to content

Commit 855de20

Browse files
author
Jon Wayne Parrott
committed
Merge pull request GoogleCloudPlatform#36 from GoogleCloudPlatform/pytest-refactor-nox-sessions
Adding nox sessions to run tests on jenkins and travis
2 parents f8970fd + 0917375 commit 855de20

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ before_install:
99
install:
1010
- pip install nox-automation tox
1111
script:
12-
- nox --session reqcheck lint
12+
- nox --session reqcheck lint travis

nox.py

+33
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
from glob import glob
2+
import shutil
3+
4+
import nox
25

36
REPO_TOOLS_REQ =\
47
'git+https://github.com/GoogleCloudPlatform/python-repo-tools.git'
58

9+
DIRS = [
10+
'1-hello-world',
11+
'2-structured-data',
12+
'3-binary-data',
13+
'4-auth',
14+
'5-logging',
15+
'6-pubsub',
16+
'7-gce']
17+
618

719
def session_reqcheck(session):
820
session.install(REPO_TOOLS_REQ)
@@ -21,3 +33,24 @@ def session_lint(session):
2133
session.run(
2234
'flake8', '--exclude=env,.nox,._config.py',
2335
'--import-order-style=google', '.')
36+
37+
38+
@nox.parametrize('dir', DIRS)
39+
def session_run_tests(session, dir=None, toxargs=None):
40+
"""Run all tests for all directories (slow!)"""
41+
session.chdir(dir)
42+
session.run('tox', *(toxargs or []))
43+
44+
45+
@nox.parametrize('dir', DIRS)
46+
def session_travis(session, dir=None):
47+
"""On travis, only run the py3.4 and cloudsql tests."""
48+
if dir == '1-hello-world':
49+
session_run_tests(
50+
session, dir=dir, toxargs=['-e', 'lint'])
51+
else:
52+
shutil.copy('config.py', dir)
53+
session_run_tests(
54+
session,
55+
dir=dir,
56+
toxargs=['-e', 'py34', '--', '-k', 'cloudsql'])

0 commit comments

Comments
 (0)