xref: /sqlalchemy/tox.ini (revision 23721113)
16b051503SMike Bayer
29281e700SMike Bayer[tox]
3c312b3b2SMike Bayerenvlist = py
49281e700SMike Bayer
59281e700SMike Bayer[testenv]
649dfeda6SMike Bayer# note that we have a .coveragerc file that points coverage specifically
749dfeda6SMike Bayer# at ./lib/sqlalchemy, and *not* at the build that tox might create under .tox.
849dfeda6SMike Bayer# See the notes below for setenv for more detail.
949dfeda6SMike Bayer# also using --cov-append so that we can aggregate multiple runs together.
1049dfeda6SMike Bayer# Jenkins etc. need to call "coverage erase" externally.
1149dfeda6SMike Bayercov_args=--cov=sqlalchemy --cov-report term --cov-append --cov-report xml --exclude-tag memory-intensive --exclude-tag timing-intensive -k "not aaa_profiling"
1249dfeda6SMike Bayer
13f704f47aSMike Bayerinstall_command=python -m pip install {env:TOX_PIP_OPTS:} {opts} {packages}
1422800000SMike Bayer
15086ad9ceSMike Bayerusedevelop=
16086ad9ceSMike Bayer     cov: True
17d100bfcfSMike Bayer
18f1e96cb0SMike Bayerdeps=
19f1e96cb0SMike Bayer     pytest>=4.6.11,<5.0; python_version < '3'
20f1e96cb0SMike Bayer     pytest>=6.2; python_version >= '3'
213568e508SMike Bayer     pytest-xdist
220396fb76SMike Bayer     mock; python_version < '3.3'
23b6f83d60SMike Bayer
24502be87aSFederico Caselli     sqlite: .[aiosqlite]
25502be87aSFederico Caselli     sqlite_file: .[aiosqlite]
26ff1d989cSMike Bayer     sqlite_file: .[sqlcipher]; python_version >= '3' and python_version < '3.10'
27897cd176SMike Bayer     postgresql: .[postgresql]
2806f1929bSTony Locke     postgresql: .[postgresql_asyncpg]; python_version >= '3'
2906f1929bSTony Locke     postgresql: .[postgresql_pg8000]; python_version >= '3'
30b6f83d60SMike Bayer
31897cd176SMike Bayer     mysql: .[mysql]
32897cd176SMike Bayer     mysql: .[pymysql]
3311eecfacSlong     mysql: .[asyncmy]; python_version >= '3'
34603f7d30SGeorg Richter     mysql: .[mariadb_connector]; python_version >= '3'
35603f7d30SGeorg Richter
36897cd176SMike Bayer     oracle: .[oracle]
37b6f83d60SMike Bayer
38897cd176SMike Bayer     mssql: .[mssql]
39d1fe8f43SMike Bayer
40b91e76a4SMike Bayer     dbapimain-sqlite: git+https://github.com/omnilib/aiosqlite.git#egg=aiosqlite
41b91e76a4SMike Bayer     dbapimain-sqlite: git+https://github.com/coleifer/sqlcipher3.git#egg=sqlcipher3
424476dca0SMike Bayer
43b91e76a4SMike Bayer     dbapimain-postgresql: git+https://github.com/psycopg/psycopg2.git#egg=psycopg2
44b91e76a4SMike Bayer     dbapimain-postgresql: git+https://github.com/MagicStack/asyncpg.git#egg=asyncpg
45b91e76a4SMike Bayer     dbapimain-postgresql: git+https://github.com/tlocke/pg8000.git#egg=pg8000
46b6f83d60SMike Bayer
47b91e76a4SMike Bayer     dbapimain-mysql: git+https://github.com/PyMySQL/mysqlclient-python.git#egg=mysqlclient
48b91e76a4SMike Bayer     dbapimain-mysql: git+https://github.com/PyMySQL/PyMySQL.git#egg=pymysql
49b91e76a4SMike Bayer     dbapimain-mysql: git+https://github.com/mariadb-corporation/mariadb-connector-python#egg=mariadb
50b6f83d60SMike Bayer
51b91e76a4SMike Bayer     dbapimain-oracle: git+https://github.com/oracle/python-cx_Oracle.git#egg=cx_Oracle
52b6f83d60SMike Bayer
53b91e76a4SMike Bayer     dbapimain-mssql: git+https://github.com/mkleehammer/pyodbc.git#egg=pyodbc
54b6f83d60SMike Bayer
55d100bfcfSMike Bayer     cov: pytest-cov
569281e700SMike Bayer
57f6fca84aSjonathan vanascoallowlist_externals=sh
5849dfeda6SMike Bayer
5949dfeda6SMike Bayer# PYTHONPATH - erased so that we use the build that's present
6049dfeda6SMike Bayer# in .tox as the SQLAlchemy library to be imported
6149dfeda6SMike Bayer#
6249dfeda6SMike Bayer# PYTHONUSERSITE - this *MUST* be set so that the ./lib/ import
6349dfeda6SMike Bayer# set up explicitly in test/conftest.py is *disabled*, again so that
6449dfeda6SMike Bayer# when SQLAlchemy is built into the .tox area, we use that and not the
6549dfeda6SMike Bayer# local checkout, at least when usedevelop=False
6649dfeda6SMike Bayer#
6749dfeda6SMike Bayer# BASECOMMAND - using an env variable here so we can use it
6849dfeda6SMike Bayer# as a substitution in a command (see https://bitbucket.org/hpk42/tox/issues/307/)
6949dfeda6SMike Bayer#
70ffb6fbf8SMike Bayer# only use --dropfirst option if we're *not* using -n;
71ffb6fbf8SMike Bayer# if -n is used, we're working in brand new DBs anyway, dropfirst
72ffb6fbf8SMike Bayer# will collide on CI environments
73f30e35baSMike Bayersetenv=
74f30e35baSMike Bayer    PYTHONPATH=
7549dfeda6SMike Bayer    PYTHONNOUSERSITE=1
76e2d4b2e7SMike Bayer    MEMUSAGE=--nomemory
775edb931eSMike Bayer    BASECOMMAND=python -m pytest --rootdir {toxinidir} --log-info=sqlalchemy.testing
78086ad9ceSMike Bayer
793ceb87daSMike Bayer    WORKERS={env:TOX_WORKERS:-n4  --max-worker-restart=5}
803231e281SMike Bayer
81086ad9ceSMike Bayer    nocext: DISABLE_SQLALCHEMY_CEXT=1
82a54a0c6eSMike Bayer    cext: REQUIRE_SQLALCHEMY_CEXT=1
83086ad9ceSMike Bayer    cov: COVERAGE={[testenv]cov_args}
843231e281SMike Bayer    backendonly: BACKENDONLY=--backend-only
853231e281SMike Bayer    memusage: MEMUSAGE='-k test_memusage'
863231e281SMike Bayer
873231e281SMike Bayer    oracle: WORKERS={env:TOX_WORKERS:-n2  --max-worker-restart=5}
883231e281SMike Bayer    oracle: ORACLE={env:TOX_ORACLE:--db oracle}
893231e281SMike Bayer
909e6393c6SMike Bayer    sqlite: SQLITE={env:TOX_SQLITE:--db sqlite}
9179a53645SGord Thompson    sqlite_file: SQLITE={env:TOX_SQLITE_FILE:--db sqlite_file}
92502be87aSFederico Caselli    py3{,5,6,7,8,9,10,11}-sqlite: EXTRA_SQLITE_DRIVERS={env:EXTRA_SQLITE_DRIVERS:--dbdriver sqlite --dbdriver aiosqlite}
93ff1d989cSMike Bayer    py3{,5,6,7,8,9}-sqlite_file: EXTRA_SQLITE_DRIVERS={env:EXTRA_SQLITE_DRIVERS:--dbdriver sqlite --dbdriver aiosqlite --dbdriver pysqlcipher}
94ff1d989cSMike Bayer    # omit pysqlcipher for Python 3.10
95ff1d989cSMike Bayer    py3{,10,11}-sqlite_file: EXTRA_SQLITE_DRIVERS={env:EXTRA_SQLITE_DRIVERS:--dbdriver sqlite --dbdriver aiosqlite}
963231e281SMike Bayer
973231e281SMike Bayer    postgresql: POSTGRESQL={env:TOX_POSTGRESQL:--db postgresql}
98f1e96cb0SMike Bayer    py2{,7}-postgresql: POSTGRESQL={env:TOX_POSTGRESQL_PY2K:{env:TOX_POSTGRESQL:--db postgresql}}
992581655cSFederico Caselli    py3{,5,6,7,8,9,10,11}-postgresql: EXTRA_PG_DRIVERS={env:EXTRA_PG_DRIVERS:--dbdriver psycopg2 --dbdriver asyncpg --dbdriver pg8000}
1003231e281SMike Bayer
1013231e281SMike Bayer    mysql: MYSQL={env:TOX_MYSQL:--db mysql}
102f1e96cb0SMike Bayer    py2{,7}-mysql: MYSQL={env:TOX_MYSQL_PY2K:{env:TOX_MYSQL:--db mysql}}
1033231e281SMike Bayer    mysql: EXTRA_MYSQL_DRIVERS={env:EXTRA_MYSQL_DRIVERS:--dbdriver mysqldb --dbdriver pymysql}
104ff1d989cSMike Bayer
10523721113SMike Bayer    py3-mysql: EXTRA_MYSQL_DRIVERS={env:EXTRA_MYSQL_DRIVERS:--dbdriver mysqldb --dbdriver pymysql --dbdriver mariadbconnector --dbdriver asyncmy}
1063231e281SMike Bayer
10706f1929bSTony Locke
108f87570acSMike Bayer    mssql: MSSQL={env:TOX_MSSQL:--db mssql}
1093231e281SMike Bayer
11079a53645SGord Thompson    oracle,mssql,sqlite_file: IDENTS=--write-idents db_idents.txt
111e2d4b2e7SMike Bayer    oracle,mssql,sqlite_file: MEMUSAGE=--nomemory
112f30e35baSMike Bayer
1137f423e87SMike Bayer# tox as of 2.0 blocks all environment variables from the
1147f423e87SMike Bayer# outside, unless they are here (or in TOX_TESTENV_PASSENV,
115077f26afSMike Bayer# wildcards OK).  Need at least these
116502be87aSFederico Casellipassenv=ORACLE_HOME NLS_LANG TOX_POSTGRESQL TOX_POSTGRESQL_PY2K TOX_MYSQL TOX_MYSQL_PY2K TOX_ORACLE TOX_MSSQL TOX_SQLITE TOX_SQLITE_FILE TOX_WORKERS EXTRA_SQLITE_DRIVERS EXTRA_PG_DRIVERS EXTRA_MYSQL_DRIVERS
1177f423e87SMike Bayer
11849dfeda6SMike Bayer# for nocext, we rm *.so in lib in case we are doing usedevelop=True
1199281e700SMike Bayercommands=
120c312b3b2SMike Bayer  cext: /bin/true
1212efd89d0SMike Bayer  nocext: sh -c "rm -f lib/sqlalchemy/*.so"
122502be87aSFederico Caselli  {env:BASECOMMAND} {env:WORKERS} {env:SQLITE:} {env:EXTRA_SQLITE_DRIVERS:} {env:POSTGRESQL:} {env:EXTRA_PG_DRIVERS:} {env:MYSQL:} {env:EXTRA_MYSQL_DRIVERS:} {env:ORACLE:} {env:MSSQL:} {env:BACKENDONLY:} {env:IDENTS:} {env:MEMUSAGE:} {env:COVERAGE:} {posargs}
12379a53645SGord Thompson  oracle,mssql,sqlite_file: python reap_dbs.py db_idents.txt
1249281e700SMike Bayer
1255f8ee392SMike Bayer
1265f8ee392SMike Bayer[testenv:mypy]
1275f8ee392SMike Bayerdeps=
1285f8ee392SMike Bayer     pytest>=6.2; python_version >= '3'
1295f8ee392SMike Bayer     pytest-xdist
1305f8ee392SMike Bayer     greenlet != 0.4.17
1315f8ee392SMike Bayer     mock; python_version < '3.3'
1325f8ee392SMike Bayer     importlib_metadata; python_version < '3.8'
1335f8ee392SMike Bayer     mypy
134803a2373SMike Bayer     patch==1.*
1355f8ee392SMike Bayer     git+https://github.com/sqlalchemy/sqlalchemy2-stubs
1365f8ee392SMike Bayercommands =
1375f8ee392SMike Bayer    pytest test/ext/mypy/test_mypy_plugin_py3k.py {posargs}
1385f8ee392SMike Bayer
139d229360aSMike Bayer# thanks to https://julien.danjou.info/the-best-flake8-extensions/
1409281e700SMike Bayer[testenv:pep8]
141e8ff0af8SMike Bayerbasepython = python3
142d229360aSMike Bayerdeps=
143d229360aSMike Bayer      flake8
144d229360aSMike Bayer      flake8-import-order
145d229360aSMike Bayer      flake8-builtins
146a55a1a41SMike Bayer      flake8-docstrings>=1.3.1
147d229360aSMike Bayer      flake8-rst-docstrings
1483ea321ceSKevin Kirsche      # flake8-rst-docstrings dependency, leaving it here
149a55a1a41SMike Bayer      # in case it requires a version pin
150a55a1a41SMike Bayer      pydocstyle
151d229360aSMike Bayer      pygments
152debeea97SFederico Caselli      black==21.5b1
153d8378f45SFederico Casellicommands =
1547ff6cf1eSMike Bayer     flake8 ./lib/ ./test/ ./examples/ setup.py doc/build/conf.py {posargs}
155255a8844SMike Bayer     black --check ./lib/ ./test/ ./examples/ setup.py doc/build/conf.py
156c658540bSFederico Caselli
157c658540bSFederico Caselli# command run in the github action when cext are active.
158c658540bSFederico Caselli[testenv:github-cext]
159b1c50ad2SFederico Casellideps = {[testenv]deps}
160b1c50ad2SFederico Caselli       .[aiosqlite]
161c658540bSFederico Casellicommands=
162e2d4b2e7SMike Bayer  python -m pytest {env:WORKERS} {env:SQLITE:} {env:POSTGRESQL:} {env:MYSQL:} {env:ORACLE:} {env:MSSQL:} {env:BACKENDONLY:} {env:IDENTS:} {env:MEMUSAGE:} {env:COVERAGE:} {posargs}
163c658540bSFederico Caselli  oracle,mssql,sqlite_file: python reap_dbs.py db_idents.txt
164c658540bSFederico Caselli
165c658540bSFederico Caselli# command run in the github action when cext are not active.
166c658540bSFederico Caselli[testenv:github-nocext]
167b1c50ad2SFederico Casellideps = {[testenv]deps}
168b1c50ad2SFederico Caselli       .[aiosqlite]
169c658540bSFederico Casellicommands=
170e2d4b2e7SMike Bayer  python -m pytest {env:WORKERS} {env:SQLITE:} {env:POSTGRESQL:} {env:MYSQL:} {env:ORACLE:} {env:MSSQL:} {env:BACKENDONLY:} {env:IDENTS:} {env:MEMUSAGE:} {env:COVERAGE:} {posargs}
1717ff6cf1eSMike Bayer  oracle,mssql,sqlite_file: python reap_dbs.py db_idents.txt
172