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