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