# Tox (http://tox.testrun.org/) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.

[tox]
envlist =
    fmt
    lint
    pyright
    mypy
    py{312,311,310,39,38,37,36,py3}
ignore_base_python_conflict = false

[tool:pytest]
testpaths = tests
addopts =
    --cov-report=term-missing

[testenv]
description = run the unit tests under {basepython}
setenv =
    COVERAGE_FILE = {toxworkdir}/.coverage.{envname}
deps =
  -r test-requirements.txt

# ignore stripe directory as all tests are inside ./tests
commands = pytest --cov {posargs:-n auto} --ignore stripe
# compilation flags can be useful when prebuilt wheels cannot be used, e.g.
# PyPy 2 needs to compile the `cryptography` module. On macOS this can be done
# by passing the following flags:
# LDFLAGS="-L$(brew --prefix openssl@1.1)/lib"
# CFLAGS="-I$(brew --prefix openssl@1.1)/include"
passenv = LDFLAGS,CFLAGS

[testenv:{lint,fmt,pyright,mypy}]
basepython = python3.10
skip_install = true
commands =
  pyright: pyright {posargs}
  lint: python -m flake8  --show-source stripe tests setup.py
  fmt: ruff format . {posargs}
  mypy: mypy {posargs}
deps =
  -r requirements.txt

[testenv:coveralls]
description = upload coverage to coveralls.io
skip_install = true
setenv =
    COVERAGE_FILE = {toxworkdir}/.coverage
passenv = GITHUB_*
commands =
    coverage combine
    coveralls --service=github
depends = py{312,311,310,39,38,37,36,py3}
