]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- restore the use of PYTHONNOUSERSITE that was removed
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 27 Jan 2016 19:23:33 +0000 (14:23 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 27 Jan 2016 19:23:33 +0000 (14:23 -0500)
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.

test/conftest.py
tox.ini

index 36dfaa79267a5bc8ac5b9122f9101b4120322316..9488a7159fad243d5a4cc6344b1d4ffa018e50b6 100755 (executable)
@@ -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
+
diff --git a/tox.ini b/tox.ini
index 8170cb5982a3826076d7c333573f9ec2d93eeb76..fee775625f4a43c36fc9760986386eaae2c2d407 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -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