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