xref: /sqlalchemy/tox.ini (revision 11eecfac)
1
2[tox]
3envlist = py
4
5[testenv]
6# note that we have a .coveragerc file that points coverage specifically
7# at ./lib/sqlalchemy, and *not* at the build that tox might create under .tox.
8# See the notes below for setenv for more detail.
9# also using --cov-append so that we can aggregate multiple runs together.
10# Jenkins etc. need to call "coverage erase" externally.
11cov_args=--cov=sqlalchemy --cov-report term --cov-append --cov-report xml --exclude-tag memory-intensive --exclude-tag timing-intensive -k "not aaa_profiling"
12
13install_command=python -m pip install {env:TOX_PIP_OPTS:} {opts} {packages}
14
15usedevelop=
16     cov: True
17
18deps=
19     pytest>=4.6.11,<5.0; python_version < '3'
20     pytest>=6.2; python_version >= '3'
21     pytest-xdist
22     mock; python_version < '3.3'
23
24     sqlite: .[aiosqlite]
25     sqlite_file: .[aiosqlite]
26     sqlite_file: .[sqlcipher]; python_version >= '3' and python_version < '3.10'
27     postgresql: .[postgresql]
28     postgresql: .[postgresql_asyncpg]; python_version >= '3'
29     postgresql: .[postgresql_pg8000]; python_version >= '3'
30
31     mysql: .[mysql]
32     mysql: .[pymysql]
33     mysql: git+https://github.com/sqlalchemy/aiomysql@sqlalchemy_tox; python_version >= '3'
34     mysql: .[asyncmy]; python_version >= '3'
35     mysql: .[mariadb_connector]; python_version >= '3'
36
37     oracle: .[oracle]
38
39     mssql: .[mssql]
40
41     dbapimaster-sqlite: git+https://github.com/omnilib/aiosqlite.git#egg=aiosqlite
42     dbapimaster-sqlite: git+https://github.com/coleifer/sqlcipher3.git#egg=sqlcipher3
43
44     dbapimaster-postgresql: git+https://github.com/psycopg/psycopg2.git@master#egg=psycopg2
45     dbapimaster-postgresql: git+https://github.com/MagicStack/asyncpg.git#egg=asyncpg
46     dbapimaster-postgresql: git+https://github.com/tlocke/pg8000.git#egg=pg8000
47
48     dbapimaster-mysql: git+https://github.com/PyMySQL/mysqlclient-python.git@master#egg=mysqlclient
49     dbapimaster-mysql: git+https://github.com/PyMySQL/PyMySQL.git@master#egg=pymysql
50     dbapimaster-mysql: git+https://github.com/mariadb-corporation/mariadb-connector-python@master#egg=mariadb
51
52     dbapimaster-oracle: git+https://github.com/oracle/python-cx_Oracle.git@main#egg=cx_Oracle
53
54     dbapimaster-mssql: git+https://github.com/mkleehammer/pyodbc.git@master#egg=pyodbc
55
56     cov: pytest-cov
57
58allowlist_externals=sh
59
60# PYTHONPATH - erased so that we use the build that's present
61# in .tox as the SQLAlchemy library to be imported
62#
63# PYTHONUSERSITE - this *MUST* be set so that the ./lib/ import
64# set up explicitly in test/conftest.py is *disabled*, again so that
65# when SQLAlchemy is built into the .tox area, we use that and not the
66# local checkout, at least when usedevelop=False
67#
68# BASECOMMAND - using an env variable here so we can use it
69# as a substitution in a command (see https://bitbucket.org/hpk42/tox/issues/307/)
70#
71# only use --dropfirst option if we're *not* using -n;
72# if -n is used, we're working in brand new DBs anyway, dropfirst
73# will collide on CI environments
74setenv=
75    PYTHONPATH=
76    PYTHONNOUSERSITE=1
77    MEMUSAGE=--nomemory
78    BASECOMMAND=python -m pytest --rootdir {toxinidir} --log-info=sqlalchemy.testing
79
80    WORKERS={env:TOX_WORKERS:-n4  --max-worker-restart=5}
81
82    nocext: DISABLE_SQLALCHEMY_CEXT=1
83    cext: REQUIRE_SQLALCHEMY_CEXT=1
84    cov: COVERAGE={[testenv]cov_args}
85    backendonly: BACKENDONLY=--backend-only
86    memusage: MEMUSAGE='-k test_memusage'
87
88    oracle: WORKERS={env:TOX_WORKERS:-n2  --max-worker-restart=5}
89    oracle: ORACLE={env:TOX_ORACLE:--db oracle}
90
91    sqlite: SQLITE={env:TOX_SQLITE:--db sqlite}
92    sqlite_file: SQLITE={env:TOX_SQLITE_FILE:--db sqlite_file}
93    py3{,5,6,7,8,9,10,11}-sqlite: EXTRA_SQLITE_DRIVERS={env:EXTRA_SQLITE_DRIVERS:--dbdriver sqlite --dbdriver aiosqlite}
94    py3{,5,6,7,8,9}-sqlite_file: EXTRA_SQLITE_DRIVERS={env:EXTRA_SQLITE_DRIVERS:--dbdriver sqlite --dbdriver aiosqlite --dbdriver pysqlcipher}
95    # omit pysqlcipher for Python 3.10
96    py3{,10,11}-sqlite_file: EXTRA_SQLITE_DRIVERS={env:EXTRA_SQLITE_DRIVERS:--dbdriver sqlite --dbdriver aiosqlite}
97
98    postgresql: POSTGRESQL={env:TOX_POSTGRESQL:--db postgresql}
99    py2{,7}-postgresql: POSTGRESQL={env:TOX_POSTGRESQL_PY2K:{env:TOX_POSTGRESQL:--db postgresql}}
100    py3{,5,6,7,8,9,10,11}-postgresql: EXTRA_PG_DRIVERS={env:EXTRA_PG_DRIVERS:--dbdriver psycopg2 --dbdriver asyncpg --dbdriver pg8000}
101
102    mysql: MYSQL={env:TOX_MYSQL:--db mysql}
103    py2{,7}-mysql: MYSQL={env:TOX_MYSQL_PY2K:{env:TOX_MYSQL:--db mysql}}
104    mysql: EXTRA_MYSQL_DRIVERS={env:EXTRA_MYSQL_DRIVERS:--dbdriver mysqldb --dbdriver pymysql}
105
106    py3{,5,6,7,8,9}-mysql: EXTRA_MYSQL_DRIVERS={env:EXTRA_MYSQL_DRIVERS:--dbdriver mysqldb --dbdriver pymysql --dbdriver mariadbconnector --dbdriver aiomysql --dbdriver asyncmy}
107    # omit aiomysql for Python 3.10
108    py3{,10,11}-mysql: EXTRA_MYSQL_DRIVERS={env:EXTRA_MYSQL_DRIVERS:--dbdriver mysqldb --dbdriver pymysql --dbdriver mariadbconnector --dbdriver asyncmy}
109
110
111    mssql: MSSQL={env:TOX_MSSQL:--db mssql}
112
113    oracle,mssql,sqlite_file: IDENTS=--write-idents db_idents.txt
114    oracle,mssql,sqlite_file: MEMUSAGE=--nomemory
115
116# tox as of 2.0 blocks all environment variables from the
117# outside, unless they are here (or in TOX_TESTENV_PASSENV,
118# wildcards OK).  Need at least these
119passenv=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
120
121# for nocext, we rm *.so in lib in case we are doing usedevelop=True
122commands=
123  cext: /bin/true
124  nocext: sh -c "rm -f lib/sqlalchemy/*.so"
125  {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}
126  oracle,mssql,sqlite_file: python reap_dbs.py db_idents.txt
127
128
129[testenv:mypy]
130deps=
131     pytest>=6.2; python_version >= '3'
132     pytest-xdist
133     greenlet != 0.4.17
134     mock; python_version < '3.3'
135     importlib_metadata; python_version < '3.8'
136     mypy
137     patch==1.*
138     git+https://github.com/sqlalchemy/sqlalchemy2-stubs
139commands =
140    pytest test/ext/mypy/test_mypy_plugin_py3k.py {posargs}
141
142# thanks to https://julien.danjou.info/the-best-flake8-extensions/
143[testenv:pep8]
144basepython = python3
145deps=
146      flake8
147      flake8-import-order
148      flake8-builtins
149      flake8-docstrings>=1.3.1
150      flake8-rst-docstrings
151      # flake8-rst-docstrings dependency, leaving it here
152      # in case it requires a version pin
153      pydocstyle
154      pygments
155      black==21.5b1
156commands =
157     flake8 ./lib/ ./test/ ./examples/ setup.py doc/build/conf.py {posargs}
158     black --check ./lib/ ./test/ ./examples/ setup.py doc/build/conf.py
159
160# command run in the github action when cext are active.
161[testenv:github-cext]
162deps = {[testenv]deps}
163       .[aiosqlite]
164commands=
165  python -m pytest {env:WORKERS} {env:SQLITE:} {env:POSTGRESQL:} {env:MYSQL:} {env:ORACLE:} {env:MSSQL:} {env:BACKENDONLY:} {env:IDENTS:} {env:MEMUSAGE:} {env:COVERAGE:} {posargs}
166  oracle,mssql,sqlite_file: python reap_dbs.py db_idents.txt
167
168# command run in the github action when cext are not active.
169[testenv:github-nocext]
170deps = {[testenv]deps}
171       .[aiosqlite]
172commands=
173  python -m pytest {env:WORKERS} {env:SQLITE:} {env:POSTGRESQL:} {env:MYSQL:} {env:ORACLE:} {env:MSSQL:} {env:BACKENDONLY:} {env:IDENTS:} {env:MEMUSAGE:} {env:COVERAGE:} {posargs}
174  oracle,mssql,sqlite_file: python reap_dbs.py db_idents.txt
175