Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tox.ini to easily test multiple Python versions #343

Merged
merged 8 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from 7 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: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,17 @@ jobs:
allow-prereleases: true
cache: pip
cache-dependency-path: |
.github/workflows/ci.yml
dev-requirements.txt
requirements.txt

- name: Install dependencies
run: |
python3 -m pip install -U -r dev-requirements.txt
python3 -m pip install -U coverage tox

- name: Tests
run: |
python3 -m coverage run -m pytest
python3 -m coverage report
python3 -m coverage xml
tox -e py

- name: Upload coverage
uses: codecov/codecov-action@v3
Expand Down
9 changes: 8 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
[pytest]
addopts = --strict-config --strict-markers
addopts =
--strict-config
--strict-markers
--cov blurb_it
--cov tests
--cov-report html
--cov-report term
--cov-report xml
Comment on lines +5 to +9
Copy link
Member

@AlexWaygood AlexWaygood Oct 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The disadvantage of putting this config in pytest.ini rather than .coveragerc is that running pytest locally will now run pytest under coverage -- there's now no way to "just run pytest without a coverage report". Whereas if the config was in .coveragerc, we could run pytest locally to run the tests, and coverage run -m pytest to run the tests under coverage.

The tests in this repo are (at the moment) extremely fast, however, so there's not really any reason to not run tests under coverage. So I'm okay with this!

xfail_strict = True
asyncio_mode = auto
filterwarnings = error
Expand Down
14 changes: 14 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[tox]
requires =
tox>=4.2
env_list =
py{312, 311, 310, 39, 38}

[testenv]
pass_env =
FORCE_COLOR
commands_pre =
{envpython} -m pip install -U -r dev-requirements.txt
commands =
{envpython} -m pytest \
{posargs}
hugovk marked this conversation as resolved.
Show resolved Hide resolved