[tox]
envlist = py

[testenv]
cov_args=--cov=dogpile --cov-append --cov-report term --cov-report xml


setenv=
    BASECOMMAND=python -m pytest

    {generic}:  RUNTESTS=-k 'not test_dbm_backend and not test_memcached_backend and not test_redis_backend'

    {memcached}: PIFPAF=pifpaf --env-prefix DOGPILE run memcached --port {env:TOX_DOGPILE_PORT:11234} --
    {memcached}: PIFPAF_TLS=pifpaf --env-prefix DOGPILE_TLS run memcached --port {env:TOX_DOGPILE_TLS_PORT:11212} --ssl_chain_cert=tests/tls/server_chain.pem --ssl_key=tests/tls/server.key --
    {memcached}: RUNTESTS=tests/cache/test_memcached_backend.py

    {redis}: PIFPAF=pifpaf --env-prefix DOGPILE run redis --port {env:TOX_DOGPILE_PORT:11234} --
    {redis}: RUNTESTS=tests/cache/test_redis_backend.py

    {redis_sentinel}: PIFPAF=pifpaf --env-prefix DOGPILE run redis --port {env:TOX_DOGPILE_PORT:11234} --sentinel --sentinel-port {env:TOX_DOGPILE_SENTINEL_PORT:11235} --
    {redis_sentinel}: RUNTESTS=tests/cache/test_redis_sentinel_backend.py

    {valkey}: PIFPAF=pifpaf --env-prefix DOGPILE run valkey --port {env:TOX_DOGPILE_PORT:11234} --
    {valkey}: RUNTESTS=tests/cache/test_valkey_backend.py

    {valkey_sentinel}: PIFPAF=pifpaf --env-prefix DOGPILE run valkey --port {env:TOX_DOGPILE_PORT:11234} --sentinel --sentinel-port {env:TOX_DOGPILE_SENTINEL_PORT:11235} --
    {valkey_sentinel}: RUNTESTS=tests/cache/test_valkey_sentinel_backend.py

    {dbm}: RUNTESTS=tests/cache/test_dbm_backend.py

    {cov}: COVERAGE={[testenv]cov_args}

    {full}: FULL=-m ''

extras=
    {redis}: pifpaf
    {redis_sentinel}: pifpaf
    {memcached}: pifpaf
    {valkey}: pifpaf

deps=
    pytest>=5.4.0
    Mako
    decorator>=4.0.0
    # Needed for an async runner test.
    # wait for https://github.com/lericson/pylibmc/issues/288 for py312
    {memcached}: pylibmc;python_version<'3.12'

    # the py3k python-memcached fails for multiple
    # delete
    {memcached}: python-memcached
    {memcached}: python-binary-memcached>=0.29.0
    {memcached}: pymemcache>=3.5.0
    {redis}: redis>=3.4.0
    {redis_sentinel}: redis>=3.4.0
    {valkey}: valkey
    {valkey_sentinel}: valkey
    {cov}: pytest-cov

commands=
  {env:PIFPAF:} {env:PIFPAF_TLS:} {env:BASECOMMAND} {env:COVERAGE:} {env:FULL:} {env:RUNTESTS:} {posargs}

sitepackages=False
usedevelop=True


[testenv:pep484]
basepython = python3
deps=
    mypy
    types-decorator
    types-redis
    redis
    valkey
    Mako
    decorator
    types-redis
    types-decorator
commands = mypy ./dogpile/

[testenv:mypy]
basepython = python3
deps=
    {[testenv:pep484]deps}
commands = mypy ./dogpile/


# thanks to https://julien.danjou.info/the-best-flake8-extensions/
[testenv:pep8]
basepython = python3
deps=
      flake8==6.1.0
      flake8-import-order
      flake8-builtins
      flake8-future-annotations>=0.0.5
      flake8-docstrings>=1.6.0
      flake8-import-single==0.1.5
      flake8-unused-arguments
      flake8-rst-docstrings
      # flake8-rst-docstrings dependency, leaving it here
      # in case it requires a version pin
      pydocstyle
      pygments
      black==23.12.0
      slotscheck>=0.17.0
commands =
    flake8 ./dogpile/ ./tests/ setup.py  {posargs}
    black --check .
