diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-01-27 14:23:33 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-01-27 14:23:33 -0500 |
commit | 49dfeda6d7578aeae9ec954945cda38ee5aae6a9 (patch) | |
tree | 7cc804636c19e96ec885c23744febe52e143dfb3 | |
parent | 8aa95fa2cd0e15b77af3e5976436adc6ed6123b9 (diff) | |
download | sqlalchemy-49dfeda6d7578aeae9ec954945cda38ee5aae6a9.tar.gz |
- restore the use of PYTHONNOUSERSITE that was removed
in df3f125bd84fc7ec5d45592c5774daf3a39d9bc9, this flag is
explicitly checked within conftest.py and we need to continue to use
it, otherwise a tox build inside of .tox that isn't usedevelop
is ignored, including C extensions
- rework the whole system of running with coverage, so that
with coverage, we *are* using usedevelop, but also make sure
we rm the .so files for nocext, make sure we --cov-append, etc.
-rwxr-xr-x | test/conftest.py | 6 | ||||
-rw-r--r-- | tox.ini | 39 |
2 files changed, 39 insertions, 6 deletions
diff --git a/test/conftest.py b/test/conftest.py index 36dfaa792..9488a7159 100755 --- a/test/conftest.py +++ b/test/conftest.py @@ -10,6 +10,11 @@ import sys import os if not sys.flags.no_user_site: + # this is needed so that test scenarios like "python setup.py test" + # work correctly, as well as plain "py.test". These commands assume + # that the package in question is locally present, but since we have + # ./lib/, we need to punch that in. + # We check no_user_site to honor the use of this flag. sys.path.insert( 0, os.path.join( @@ -28,3 +33,4 @@ with open(bootstrap_file) as f: to_bootstrap = "pytest" exec(code, globals(), locals()) from pytestplugin import * # noqa + @@ -7,7 +7,14 @@ envlist = py35-nocext-cov [testenv] -cov_args=--cov=sqlalchemy --cov-report term --cov-report xml --exclude-tag memory-intensive --exclude-tag timing-intensive -k "not aaa_profiling" +# note that we have a .coveragerc file that points coverage specifically +# at ./lib/sqlalchemy, and *not* at the build that tox might create under .tox. +# See the notes below for setenv for more detail. +# also using --cov-append so that we can aggregate multiple runs together. +# Jenkins etc. need to call "coverage erase" externally. +cov_args=--cov=sqlalchemy --cov-report term --cov-append --cov-report xml --exclude-tag memory-intensive --exclude-tag timing-intensive -k "not aaa_profiling" + +usedevelop={env:USEDEVELOP} deps=pytest pytest-xdist @@ -22,21 +29,42 @@ deps=pytest cov: .[mysql] cov: .[postgresql] -# -E : ignore PYTHON* environment variables (such as PYTHONPATH) -# BASECOMMAND: we can't do section subtitutions in commands -# (see https://bitbucket.org/hpk42/tox/issues/307/) +whitelist_externals=sh + +# PYTHONPATH - erased so that we use the build that's present +# in .tox as the SQLAlchemy library to be imported +# +# PYTHONUSERSITE - this *MUST* be set so that the ./lib/ import +# set up explicitly in test/conftest.py is *disabled*, again so that +# when SQLAlchemy is built into the .tox area, we use that and not the +# local checkout, at least when usedevelop=False +# +# BASECOMMAND - using an env variable here so we can use it +# as a substitution in a command (see https://bitbucket.org/hpk42/tox/issues/307/) +# +# USEDEVELOP - also an env variable because we can't otherwise use a factor +# to control the value of the "usedevelop" setting (should also be a tox bug) +# We want develop=True when coverage is in play, because coverage is +# always against the files physically in ./lib. We are doing an aggregate +# of coverage into one file across multiple test runs. +# setenv= PYTHONPATH= + PYTHONNOUSERSITE=1 + USEDEVELOP=False nocext: DISABLE_SQLALCHEMY_CEXT=1 BASECOMMAND=python -m pytest -n4 --dropfirst - cov: BASECOMMAND=python -m pytest -n4 --dropfirst {[testenv]cov_args} + cov: BASECOMMAND=python -m pytest -n4 --dropfirst {[testenv]cov_args} + cov: USEDEVELOP=True # tox as of 2.0 blocks all environment variables from the # outside, unless they are here (or in TOX_TESTENV_PASSENV, # wildcards OK). Need at least these passenv=ORACLE_HOME NLS_LANG +# for nocext, we rm *.so in lib in case we are doing usedevelop=True commands= + nocext: sh -c "rm -f lib/sqlalchemy/*.so" default: {env:BASECOMMAND} {posargs} sqlitepg: {env:BASECOMMAND} --db sqlite --db postgresql {posargs} mysql: {env:BASECOMMAND} --db mysql --db pymysql {posargs} @@ -48,7 +76,6 @@ commands= deps=flake8 commands = python -m flake8 {posargs} - [flake8] show-source = True ignore = E711,E712,E721,N806 |