###
### NOTE: use of tox is deprecated, and this file is no longer maintained and
### will be removed at some point.   Testing is now run via nox.
###

[tox]

envlist = py-sqlalchemy

SQLA_REPO = {env:SQLA_REPO:git+https://github.com/sqlalchemy/sqlalchemy.git}
BLACK_VERSION = 25.9.0

[testenv]
cov_args=--cov=alembic --cov-report term --cov-report xml

deps=pytest>4.6,<8.4
     pytest-xdist
     sqla14: {[tox]SQLA_REPO}@rel_1_4#egg=sqlalchemy
     sqla20: {[tox]SQLA_REPO}@rel_2_0#egg=sqlalchemy
     sqlamain: {[tox]SQLA_REPO}#egg=sqlalchemy
     postgresql: psycopg2>=2.7
     mysql: mysqlclient>=1.4.0
     mysql: pymysql
     oracle: cx_oracle>=7
     mssql: pyodbc
     cov: pytest-cov
     sqlalchemy: sqlalchemy>=1.4.0
     mako
     tzdata
     zimports
     black=={[tox]BLACK_VERSION}
     greenlet>=1



usedevelop=
     cov: True

# only use --dropfirst option if we're *not* using -n;
# if -n is used, we're working in brand new DBs anyway
setenv=
    BASECOMMAND=python -m pytest {tty:--color=yes} --rootdir {toxinidir}
    WORKERS={env:TOX_WORKERS:-n4}
    cov: COVERAGE={[testenv]cov_args}
    sqlite: SQLITE={env:TOX_SQLITE:--db sqlite}
    postgresql: POSTGRESQL={env:TOX_POSTGRESQL:--db postgresql}
    mysql: MYSQL={env:TOX_MYSQL:--db mysql}
    oracle: ORACLE={env:TOX_ORACLE:--db oracle} --low-connections --write-idents db_idents.txt
    mssql: MSSQL={env:TOX_MSSQL:--db mssql}
    pyoptimize: PYTHONOPTIMIZE=1
    pyoptimize: LIMITTESTS="tests/test_script_consumption.py"
    future: SQLALCHEMY_TESTING_FUTURE_ENGINE=1
    SQLALCHEMY_WARN_20=1


# tox as of 2.0 blocks all environment variables from the
# outside, unless they are here (or in TOX_TESTENV_PASSENV,
# wildcards OK).  Need at least these
passenv=
    ORACLE_HOME
    NLS_LANG
    TOX_SQLITE
    TOX_POSTGRESQL
    TOX_MYSQL
    TOX_ORACLE
    TOX_MSSQL

commands=
  {env:BASECOMMAND} {env:WORKERS} {env:SQLITE:} {env:POSTGRESQL:} {env:MYSQL:} {env:ORACLE:} {env:MSSQL:} {env:BACKENDONLY:} {env:COVERAGE:} {env:LIMITTESTS:} {posargs}
  {oracle,mssql}: python reap_dbs.py db_idents.txt
  python tools/warn_tox.py


[testenv:pep484]
basepython =
    python312
    python313
deps=
    mypy>=1.16.0
    sqlalchemy>=2
    mako
    # is imported in alembic/testing and mypy complains if it's not installed.
    pytest
commands = mypy ./alembic/ --exclude alembic/templates

[testenv:mypy]
basepython = {[testenv:pep484]basepython}
deps=
    {[testenv:pep484]deps}
commands = {[testenv:pep484]commands}

[testenv:pep8]
basepython = python3
deps=
      flake8
      flake8-import-order>=0.19.2
      flake8-import-single==0.1.5
      flake8-builtins
      flake8-docstrings
      flake8-rst-docstrings
      pydocstyle<4.0.0
      # used by flake8-rst-docstrings
      pygments
      black=={[tox]BLACK_VERSION}
commands =
     flake8 ./alembic/ ./tests/ setup.py docs/build/conf.py {posargs}
     black --check setup.py tests alembic

[testenv:write_pyi]
basepython = python3
deps=
    sqlalchemy>=2
    mako
    zimports
    black=={[tox]BLACK_VERSION}
commands = python tools/write_pyi.py
