|
| 1 | +# Copyright 2016 Google Inc. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +import nox |
| 16 | + |
| 17 | + |
| 18 | +@nox.session |
| 19 | +@nox.parametrize('python_version', ['2.7', '3.4', '3.5', '3.6']) |
| 20 | +def unit_tests(session, python_version): |
| 21 | + """Run the unit test suite.""" |
| 22 | + |
| 23 | + # Run unit tests against all supported versions of Python. |
| 24 | + session.interpreter = 'python%s' % python_version |
| 25 | + |
| 26 | + # Install all test dependencies, then install this package in-place. |
| 27 | + session.install('mock', 'pytest', 'pytest-cov', '../core/') |
| 28 | + session.install('-e', '.') |
| 29 | + |
| 30 | + # Run py.test against the unit tests. |
| 31 | + session.run('py.test', '--quiet', |
| 32 | + '--cov=google.cloud.pubsub', '--cov=tests.unit', '--cov-append', |
| 33 | + '--cov-config=.coveragerc', '--cov-report=', '--cov-fail-under=97', |
| 34 | + 'tests/unit', |
| 35 | + ) |
| 36 | + |
| 37 | + |
| 38 | +@nox.session |
| 39 | +@nox.parametrize('python_version', ['2.7', '3.6']) |
| 40 | +def system_tests(session, python_version): |
| 41 | + """Run the system test suite.""" |
| 42 | + |
| 43 | + # Run the system tests against latest Python 2 and Python 3 only. |
| 44 | + session.interpreter = 'python%s' % python_version |
| 45 | + |
| 46 | + # Install all test dependencies, then install this package into the |
| 47 | + # virutalenv's dist-packages. |
| 48 | + session.install('mock', 'pytest', |
| 49 | + '../core/', '../test_utils/') |
| 50 | + session.install('.') |
| 51 | + |
| 52 | + # Run py.test against the system tests. |
| 53 | + session.run('py.test', '--quiet', 'tests/system.py') |
| 54 | + |
| 55 | + |
| 56 | +@nox.session |
| 57 | +def lint(session): |
| 58 | + """Run flake8. |
| 59 | +
|
| 60 | + Returns a failure if flake8 finds linting errors or sufficiently |
| 61 | + serious code quality issues. |
| 62 | + """ |
| 63 | + session.interpreter = 'python3.6' |
| 64 | + session.install('flake8') |
| 65 | + session.install('.') |
| 66 | + session.run('flake8', 'google/cloud/pubsub') |
| 67 | + |
| 68 | + |
| 69 | +@nox.session |
| 70 | +def cover(session): |
| 71 | + """Run the final coverage report. |
| 72 | +
|
| 73 | + This outputs the coverage report aggregating coverage from the unit |
| 74 | + test runs (not system test runs), and then erases coverage data. |
| 75 | + """ |
| 76 | + session.interpreter = 'python3.6' |
| 77 | + session.install('coverage', 'pytest-cov') |
| 78 | + session.run('coverage', 'report', '--show-missing', '--fail-under=100') |
| 79 | + session.run('coverage', 'erase') |
0 commit comments