|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# |
| 3 | +# Copyright 2018 Google LLC |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +from __future__ import absolute_import |
| 18 | +import os |
| 19 | + |
| 20 | +import nox |
| 21 | + |
| 22 | + |
| 23 | +@nox.session |
| 24 | +def default(session): |
| 25 | + return unit(session, 'default') |
| 26 | + |
| 27 | + |
| 28 | +@nox.session |
| 29 | +@nox.parametrize('py', ['2.7', '3.5', '3.6', '3.7']) |
| 30 | +def unit(session, py): |
| 31 | + """Run the unit test suite.""" |
| 32 | + |
| 33 | + # Run unit tests against all supported versions of Python. |
| 34 | + if py != 'default': |
| 35 | + session.interpreter = 'python{}'.format(py) |
| 36 | + |
| 37 | + # Set the virtualenv directory name. |
| 38 | + session.virtualenv_dirname = 'unit-' + py |
| 39 | + |
| 40 | + # Install all test dependencies, then install this package in-place. |
| 41 | + session.install('pytest') |
| 42 | + session.install('-e', '.') |
| 43 | + |
| 44 | + # Run py.test against the unit tests. |
| 45 | + session.run('py.test', '--quiet', os.path.join('tests', 'unit')) |
| 46 | + |
| 47 | + |
| 48 | +@nox.session |
| 49 | +def lint_setup_py(session): |
| 50 | + """Verify that setup.py is valid (including RST check).""" |
| 51 | + session.interpreter = 'python3.6' |
| 52 | + session.install('docutils', 'pygments') |
| 53 | + session.run('python', 'setup.py', 'check', '--restructuredtext', |
| 54 | + '--strict') |
0 commit comments