|
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | 15 | from __future__ import absolute_import |
| 16 | + |
16 | 17 | import os |
17 | 18 |
|
18 | 19 | import nox |
19 | 20 |
|
20 | 21 |
|
| 22 | +LOCAL_DEPS = ( |
| 23 | + os.path.join('..', 'api_core'), |
| 24 | +) |
| 25 | + |
| 26 | + |
21 | 27 | @nox.session |
22 | | -@nox.parametrize('python_version', ['2.7', '3.4', '3.5', '3.6']) |
23 | | -def unit_tests(session, python_version): |
24 | | - """Run the unit test suite.""" |
| 28 | +def default(session): |
| 29 | + """Default unit test session. |
| 30 | +
|
| 31 | + This is intended to be run **without** an interpreter set, so |
| 32 | + that the current ``python`` (on the ``PATH``) or the version of |
| 33 | + Python corresponding to the ``nox`` binary on the ``PATH`` can |
| 34 | + run the tests. |
| 35 | + """ |
| 36 | + # Install all test dependencies, then install this package in-place. |
| 37 | + session.install('mock', 'pytest', 'pytest-cov', *LOCAL_DEPS) |
| 38 | + session.install('-e', '.') |
25 | 39 |
|
26 | | - session.interpreter = 'python{}'.format(python_version) |
| 40 | + # Run py.test against the unit tests. |
| 41 | + session.run( |
| 42 | + 'py.test', |
| 43 | + '--quiet', |
| 44 | + '--cov=google.cloud.container', |
| 45 | + '--cov=google.cloud.container_v1', |
| 46 | + '--cov=tests.unit', |
| 47 | + '--cov-append', |
| 48 | + '--cov-config=.coveragerc', |
| 49 | + '--cov-report=', |
| 50 | + os.path.join('tests', 'unit'), |
| 51 | + *session.posargs |
| 52 | + ) |
27 | 53 |
|
28 | | - session.virtualenv_dirname = 'unit-' + python_version |
29 | 54 |
|
30 | | - session.install('pytest') |
31 | | - session.install('-e', '.') |
| 55 | +@nox.session |
| 56 | +@nox.parametrize('py', ['2.7', '3.4', '3.5', '3.6']) |
| 57 | +def unit(session, py): |
| 58 | + """Run the unit test suite.""" |
32 | 59 |
|
33 | | - session.run('py.test', '--quiet', os.path.join('tests', 'unit')) |
| 60 | + session.interpreter = 'python{}'.format(py) |
| 61 | + session.virtualenv_dirname = 'unit-' + py |
| 62 | + default(session) |
34 | 63 |
|
35 | 64 |
|
36 | 65 | @nox.session |
37 | | -@nox.parametrize('python_version', ['2.7', '3.6']) |
38 | | -def system_tests(session, python_version): |
| 66 | +@nox.parametrize('py', ['2.7', '3.6']) |
| 67 | +def system(session, py): |
39 | 68 | """Run the system test suite.""" |
40 | 69 |
|
41 | 70 | # Sanity check: Only run system tests if the environment variable is set. |
42 | 71 | if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS', ''): |
43 | 72 | session.skip('Credentials must be set via environment variable.') |
44 | 73 |
|
45 | 74 | # Run the system tests against latest Python 2 and Python 3 only. |
46 | | - session.interpreter = 'python{}'.format(python_version) |
| 75 | + session.interpreter = 'python{}'.format(py) |
47 | 76 |
|
48 | 77 | # Set the virtualenv dirname. |
49 | | - session.virtualenv_dirname = 'sys-' + python_version |
| 78 | + session.virtualenv_dirname = 'sys-' + py |
50 | 79 |
|
51 | 80 | # Install all test dependencies, then install this package into the |
52 | 81 | # virtualenv's dist-packages. |
|
0 commit comments