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