|
| 1 | +# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one |
| 2 | +# or more contributor license agreements. See the NOTICE file distributed with |
| 3 | +# this work for additional information regarding copyright |
| 4 | +# ownership. Elasticsearch B.V. licenses this file to you under |
| 5 | +# the Apache License, Version 2.0 (the "License"); you may |
| 6 | +# not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://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 | +import nox |
| 18 | +import sys |
| 19 | + |
| 20 | + |
| 21 | +def run_tests(session: nox.Session, pytest_extra_args: list[str] = []): |
| 22 | + python_version = (sys.version_info.major, sys.version_info.minor, sys.version_info.micro) |
| 23 | + vcrpy_is_supported = python_version >= (3, 10, 0) |
| 24 | + |
| 25 | + session.install("-r", "dev-requirements.txt") |
| 26 | + if vcrpy_is_supported: |
| 27 | + session.install("pytest-vcr") |
| 28 | + # install the package for being able to use the entry points we define |
| 29 | + session.install("-e", ".") |
| 30 | + |
| 31 | + session.run("pytest", *pytest_extra_args, env={"EDOT_IN_NOX": "1"}) |
| 32 | + |
| 33 | + |
| 34 | +@nox.session |
| 35 | +def tests(session): |
| 36 | + run_tests(session, pytest_extra_args=session.posargs) |
0 commit comments