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