Tox - Automating Book Availability Checks
tox aims to automate and standardize testing in Python.
tox is a generic virtualenv management and test command line tool you can use for:
- checking that your package installs correctly with different Python versions and interpreters
- running your tests in each of the environments, configuring your test tool of choice
- acting as a frontend to Continuous Integration servers, greatly reducing boilerplate and merging CI and shell-based testing.
My objective here is to make sure that when I make changes to the code via a PR, tests run automatically to confirm that the code works with different versions of Python that I am interested in maintaining compatibility with.
I am using tox with uv via tox-uv, and with GHA via tox-gh.
Implementation
Done here: https://github.com/k-candidate/selenium-book-search-slack-alerts/pull/9
To test with tox locally:
git clone https://github.com/k-candidate/selenium-book-search-slack-alerts
cd selenium-book-search-slack-alerts
# Install tox outside of venv
uv tool install tox --with tox-uv
# To run just the unit tests
uv sync
source .venv/bin/activate
pytest
# To run tox we have to be outside the venv
deactivate
uvx tox

What the tox tests look like in a Github action: https://github.com/k-candidate/selenium-book-search-slack-alerts/actions/runs/19996419173/job/57344643011?pr=9

References
- https://github.com/tox-dev/tox
- https://tox.wiki/en/3.24.5/config.html
- https://docs.astral.sh/uv/guides/tools/
- https://github.com/tox-dev/tox-uv
- https://github.com/tox-dev/tox-gh
- https://www.youtube.com/watch?v=75WBE_qbpGk
- https://www.youtube.com/watch?v=Rexxs0toSjc
- https://www.youtube.com/watch?v=DhUpxWjOhME