Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,8 @@ jobs:
with:
python-version: ${{ env[matrix.python-version] }}
architecture: "x64"
- run: pip install -r dev-requirements.txt
- name: run recorded tests with python 3.10+ where urllib3 2.x is supported
run: pip install pytest-vcr
if: ${{ matrix.python-version != 'py39' }}
- run: pytest --with-integration-tests
- run: pip install nox
- run: nox -- --with-integration-tests

typecheck:
runs-on: ubuntu-latest
Expand Down
13 changes: 7 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,14 @@ Once your changes are ready to submit for review:

### Testing

To run local unit tests, you can install requirements and then run `pytest` from the project root:
To run local unit tests, you can install nox and then run `nox` from the project root:

pip install -r dev-requirements.txt
pytest
pip install nox
nox

To run also the slower integration tests you can run:

nox -- --with-integration-tests

Pytest will automatically discover tests.

Expand All @@ -91,9 +95,6 @@ dynamic discovery features. In particular,
and hard to discover, due to the fact that they do not need to be imported to
be used.

By default only unit tests are run because tests under `tests/integrations` are a bit slower.
Use `pytest --with-integration-tests` to run them.

### Workflow

All feature development and most bug fixes hit the main branch first.
Expand Down
36 changes: 36 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import nox
import sys


def run_tests(session: nox.Session, pytest_extra_args: list[str] = []):
python_version = (sys.version_info.major, sys.version_info.minor, sys.version_info.micro)
vcrpy_is_supported = python_version >= (3, 10, 0)

session.install("-r", "dev-requirements.txt")
if vcrpy_is_supported:
session.install("pytest-vcr")
# install the package for being able to use the entry points we define
session.install("-e", ".")

session.run("pytest", *pytest_extra_args, env={"EDOT_IN_NOX": "1"})


@nox.session
def tests(session):
run_tests(session, pytest_extra_args=session.posargs)