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