xref: /sqlalchemy/tox.ini (revision b6f83d60)
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
229c7fb63dSFantix King     greenlet != 0.4.17
230396fb76SMike Bayer     mock; python_version < '3.3'
24cd03b8f0SMike Bayer     importlib_metadata; python_version < '3.8'
25b6f83d60SMike Bayer
26897cd176SMike Bayer     postgresql: .[postgresql]
2706f1929bSTony Locke     postgresql: .[postgresql_asyncpg]; python_version >= '3'
2806f1929bSTony Locke     postgresql: .[postgresql_pg8000]; python_version >= '3'
29b6f83d60SMike Bayer
30897cd176SMike Bayer     mysql: .[mysql]
31897cd176SMike Bayer     mysql: .[pymysql]
3248930113SMike Bayer     mysql: git+https://github.com/sqlalchemy/aiomysql@sqlalchemy_tox; python_version >= '3'
33603f7d30SGeorg Richter     mysql: .[mariadb_connector]; python_version >= '3'
34603f7d30SGeorg Richter
35897cd176SMike Bayer     oracle: .[oracle]
36b6f83d60SMike Bayer
37897cd176SMike Bayer     mssql: .[mssql]
38d1fe8f43SMike Bayer
39b6f83d60SMike Bayer     dbapimaster-postgresql: git+https://github.com/psycopg/psycopg2.git@master#egg=psycopg2
40b6f83d60SMike Bayer     dbapimaster-postgresql: git+https://github.com/MagicStack/asyncpg.git#egg=asyncpg
41b6f83d60SMike Bayer     dbapimaster-postgresql: git+https://github.com/tlocke/pg8000.git#egg=pg8000
42b6f83d60SMike Bayer
43b6f83d60SMike Bayer     dbapimaster-mysql: git+https://github.com/PyMySQL/mysqlclient-python.git@master#egg=mysqlclient
44b6f83d60SMike Bayer     dbapimaster-mysql: git+https://github.com/PyMySQL/PyMySQL.git@master#egg=pymysql
45b6f83d60SMike Bayer     dbapimaster-mysql: git+https://github.com/mariadb-corporation/mariadb-connector-python@master#egg=mariadb
46b6f83d60SMike Bayer
47b6f83d60SMike Bayer     dbapimaster-oracle: git+https://github.com/oracle/python-cx_Oracle.git@master#egg=cx_Oracle
48b6f83d60SMike Bayer
49b6f83d60SMike Bayer     dbapimaster-mssql: git+https://github.com/mkleehammer/pyodbc.git@master#egg=pyodbc
50b6f83d60SMike Bayer
51d100bfcfSMike Bayer     cov: pytest-cov
529281e700SMike Bayer
53f6fca84aSjonathan vanascoallowlist_externals=sh
5449dfeda6SMike Bayer
5549dfeda6SMike Bayer# PYTHONPATH - erased so that we use the build that's present
5649dfeda6SMike Bayer# in .tox as the SQLAlchemy library to be imported
5749dfeda6SMike Bayer#
5849dfeda6SMike Bayer# PYTHONUSERSITE - this *MUST* be set so that the ./lib/ import
5949dfeda6SMike Bayer# set up explicitly in test/conftest.py is *disabled*, again so that
6049dfeda6SMike Bayer# when SQLAlchemy is built into the .tox area, we use that and not the
6149dfeda6SMike Bayer# local checkout, at least when usedevelop=False
6249dfeda6SMike Bayer#
6349dfeda6SMike Bayer# BASECOMMAND - using an env variable here so we can use it
6449dfeda6SMike Bayer# as a substitution in a command (see https://bitbucket.org/hpk42/tox/issues/307/)
6549dfeda6SMike Bayer#
66ffb6fbf8SMike Bayer# only use --dropfirst option if we're *not* using -n;
67ffb6fbf8SMike Bayer# if -n is used, we're working in brand new DBs anyway, dropfirst
68ffb6fbf8SMike Bayer# will collide on CI environments
69f30e35baSMike Bayersetenv=
70f30e35baSMike Bayer    PYTHONPATH=
7149dfeda6SMike Bayer    PYTHONNOUSERSITE=1
72e2d4b2e7SMike Bayer    MEMUSAGE=--nomemory
735edb931eSMike Bayer    BASECOMMAND=python -m pytest --rootdir {toxinidir} --log-info=sqlalchemy.testing
74086ad9ceSMike Bayer
753ceb87daSMike Bayer    WORKERS={env:TOX_WORKERS:-n4  --max-worker-restart=5}
763231e281SMike Bayer
77086ad9ceSMike Bayer    nocext: DISABLE_SQLALCHEMY_CEXT=1
78a54a0c6eSMike Bayer    cext: REQUIRE_SQLALCHEMY_CEXT=1
79086ad9ceSMike Bayer    cov: COVERAGE={[testenv]cov_args}
803231e281SMike Bayer    backendonly: BACKENDONLY=--backend-only
813231e281SMike Bayer    memusage: MEMUSAGE='-k test_memusage'
823231e281SMike Bayer
833231e281SMike Bayer    oracle: WORKERS={env:TOX_WORKERS:-n2  --max-worker-restart=5}
843231e281SMike Bayer    oracle: ORACLE={env:TOX_ORACLE:--db oracle}
853231e281SMike Bayer
869e6393c6SMike Bayer    sqlite: SQLITE={env:TOX_SQLITE:--db sqlite}
8779a53645SGord Thompson    sqlite_file: SQLITE={env:TOX_SQLITE_FILE:--db sqlite_file}
883231e281SMike Bayer
893231e281SMike Bayer    postgresql: POSTGRESQL={env:TOX_POSTGRESQL:--db postgresql}
90f1e96cb0SMike Bayer    py2{,7}-postgresql: POSTGRESQL={env:TOX_POSTGRESQL_PY2K:{env:TOX_POSTGRESQL:--db postgresql}}
912581655cSFederico Caselli    py3{,5,6,7,8,9,10,11}-postgresql: EXTRA_PG_DRIVERS={env:EXTRA_PG_DRIVERS:--dbdriver psycopg2 --dbdriver asyncpg --dbdriver pg8000}
923231e281SMike Bayer
933231e281SMike Bayer    mysql: MYSQL={env:TOX_MYSQL:--db mysql}
94f1e96cb0SMike Bayer    py2{,7}-mysql: MYSQL={env:TOX_MYSQL_PY2K:{env:TOX_MYSQL:--db mysql}}
953231e281SMike Bayer    mysql: EXTRA_MYSQL_DRIVERS={env:EXTRA_MYSQL_DRIVERS:--dbdriver mysqldb --dbdriver pymysql}
962581655cSFederico Caselli    py3{,5,6,7,8,9,10,11}-mysql: EXTRA_MYSQL_DRIVERS={env:EXTRA_MYSQL_DRIVERS:--dbdriver mysqldb --dbdriver pymysql --dbdriver mariadbconnector --dbdriver aiomysql}
973231e281SMike Bayer
9806f1929bSTony Locke
99f87570acSMike Bayer    mssql: MSSQL={env:TOX_MSSQL:--db mssql}
1003231e281SMike Bayer
10179a53645SGord Thompson    oracle,mssql,sqlite_file: IDENTS=--write-idents db_idents.txt
102e2d4b2e7SMike Bayer    oracle,mssql,sqlite_file: MEMUSAGE=--nomemory
103f30e35baSMike Bayer
1047f423e87SMike Bayer# tox as of 2.0 blocks all environment variables from the
1057f423e87SMike Bayer# outside, unless they are here (or in TOX_TESTENV_PASSENV,
106077f26afSMike Bayer# wildcards OK).  Need at least these
107f1e96cb0SMike Bayerpassenv=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_PG_DRIVERS EXTRA_MYSQL_DRIVERS
1087f423e87SMike Bayer
10949dfeda6SMike Bayer# for nocext, we rm *.so in lib in case we are doing usedevelop=True
1109281e700SMike Bayercommands=
111c312b3b2SMike Bayer  cext: /bin/true
1122efd89d0SMike Bayer  nocext: sh -c "rm -f lib/sqlalchemy/*.so"
1133231e281SMike Bayer  {env:BASECOMMAND} {env:WORKERS} {env:SQLITE:} {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}
11479a53645SGord Thompson  oracle,mssql,sqlite_file: python reap_dbs.py db_idents.txt
1159281e700SMike Bayer
116d229360aSMike Bayer# thanks to https://julien.danjou.info/the-best-flake8-extensions/
1179281e700SMike Bayer[testenv:pep8]
118e8ff0af8SMike Bayerbasepython = python3
119d229360aSMike Bayerdeps=
120d229360aSMike Bayer      flake8
121d229360aSMike Bayer      flake8-import-order
122d229360aSMike Bayer      flake8-builtins
123a55a1a41SMike Bayer      flake8-docstrings>=1.3.1
124d229360aSMike Bayer      flake8-rst-docstrings
125a55a1a41SMike Bayer      # flake8-rst-docstrings depdendency, leaving it here
126a55a1a41SMike Bayer      # in case it requires a version pin
127a55a1a41SMike Bayer      pydocstyle
128d229360aSMike Bayer      pygments
129c3f102c9SMike Bayer      black==20.8b1
130d8378f45SFederico Casellicommands =
1317ff6cf1eSMike Bayer     flake8 ./lib/ ./test/ ./examples/ setup.py doc/build/conf.py {posargs}
132d8378f45SFederico Caselli     black --check .
133c658540bSFederico Caselli
134c658540bSFederico Caselli# command run in the github action when cext are active.
135c658540bSFederico Caselli[testenv:github-cext]
136c658540bSFederico Casellicommands=
137e2d4b2e7SMike 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}
138c658540bSFederico Caselli  oracle,mssql,sqlite_file: python reap_dbs.py db_idents.txt
139c658540bSFederico Caselli
140c658540bSFederico Caselli# command run in the github action when cext are not active.
141c658540bSFederico Caselli[testenv:github-nocext]
142c658540bSFederico Casellicommands=
143e2d4b2e7SMike 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}
1447ff6cf1eSMike Bayer  oracle,mssql,sqlite_file: python reap_dbs.py db_idents.txt
145