xref: /sqlalchemy/tox.ini (revision ba5cbf93)
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    BASECOMMAND=python -m pytest --rootdir {toxinidir} --log-info=sqlalchemy.testing
60
61    WORKERS={env:TOX_WORKERS:-n4  --max-worker-restart=5}
62
63    nocext: DISABLE_SQLALCHEMY_CEXT=1
64    cext: REQUIRE_SQLALCHEMY_CEXT=1
65    cov: COVERAGE={[testenv]cov_args}
66    backendonly: BACKENDONLY=--backend-only
67    memusage: MEMUSAGE='-k test_memusage'
68
69    oracle: WORKERS={env:TOX_WORKERS:-n2  --max-worker-restart=5}
70    oracle: ORACLE={env:TOX_ORACLE:--db oracle}
71
72    sqlite: SQLITE={env:TOX_SQLITE:--db sqlite}
73    sqlite_file: SQLITE={env:TOX_SQLITE_FILE:--db sqlite_file}
74
75    postgresql: POSTGRESQL={env:TOX_POSTGRESQL:--db postgresql}
76    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}
77
78    mysql: MYSQL={env:TOX_MYSQL:--db mysql}
79    mysql: EXTRA_MYSQL_DRIVERS={env:EXTRA_MYSQL_DRIVERS:--dbdriver mysqldb --dbdriver pymysql}
80    py3{,5,6,7,8,9,10,11}-mysql: EXTRA_MYSQL_DRIVERS={env:EXTRA_MYSQL_DRIVERS:--dbdriver mysqldb --dbdriver pymysql --dbdriver mariadbconnector}
81
82
83    mssql: MSSQL={env:TOX_MSSQL:--db mssql}
84
85    oracle,mssql,sqlite_file: IDENTS=--write-idents db_idents.txt
86    oracle,mssql,sqlite_file: MEMUSAGE=--nomemory
87
88# tox as of 2.0 blocks all environment variables from the
89# outside, unless they are here (or in TOX_TESTENV_PASSENV,
90# wildcards OK).  Need at least these
91passenv=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
92
93# for nocext, we rm *.so in lib in case we are doing usedevelop=True
94commands=
95  cext: /bin/true
96  nocext: sh -c "rm -f lib/sqlalchemy/*.so"
97  {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}
98  oracle,mssql,sqlite_file: python reap_dbs.py db_idents.txt
99
100# thanks to https://julien.danjou.info/the-best-flake8-extensions/
101[testenv:pep8]
102basepython = python3.7
103deps=
104      flake8
105      flake8-import-order
106      flake8-builtins
107      flake8-docstrings>=1.3.1
108      flake8-rst-docstrings
109      # flake8-rst-docstrings depdendency, leaving it here
110      # in case it requires a version pin
111      pydocstyle
112      pygments
113      black==20.8b1
114commands =
115     flake8 ./lib/ ./test/ ./examples/ setup.py doc/build/conf.py {posargs}
116     black --check .
117
118# command run in the github action when cext are active.
119[testenv:github-cext]
120commands=
121  python -m pytest {env:WORKERS} {env:SQLITE:} {env:POSTGRESQL:} {env:MYSQL:} {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# command run in the github action when cext are not active.
125[testenv:github-nocext]
126commands=
127  python -m pytest {env:WORKERS} {env:SQLITE:} {env:POSTGRESQL:} {env:MYSQL:} {env:ORACLE:} {env:MSSQL:} {env:BACKENDONLY:} {env:IDENTS:} {env:MEMUSAGE:} {env:COVERAGE:} {posargs}
128  oracle,mssql,sqlite_file: python reap_dbs.py db_idents.txt
129