diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-04-04 19:08:18 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-04-04 19:08:18 -0400 |
commit | f30e35babc63f5613537bb62aef6acb26dadd503 (patch) | |
tree | 118c4a736c69167a1bc4057045a7e9fbda8a315e | |
parent | ecd7b31d5eaed138e699293719f70260da3c978d (diff) | |
download | sqlalchemy-f30e35babc63f5613537bb62aef6acb26dadd503.tar.gz |
- Fixed the pathing used when tests run; for sqla_nose.py and py.test,
the "./lib" prefix is again inserted at the head of sys.path but
only if sys.flags.no_user_site isn't set; this makes it act just
like the way Python puts "." in the current path by default.
For tox, we are setting the PYTHONNOUSERSITE flag now.
fixes #3356
-rw-r--r-- | doc/build/changelog/changelog_10.rst | 10 | ||||
-rw-r--r-- | regen_callcounts.tox.ini | 8 | ||||
-rwxr-xr-x | sqla_nose.py | 9 | ||||
-rwxr-xr-x | test/conftest.py | 10 | ||||
-rw-r--r-- | tox.ini | 18 |
5 files changed, 42 insertions, 13 deletions
diff --git a/doc/build/changelog/changelog_10.rst b/doc/build/changelog/changelog_10.rst index 7b101389d..6f2e1542b 100644 --- a/doc/build/changelog/changelog_10.rst +++ b/doc/build/changelog/changelog_10.rst @@ -19,6 +19,16 @@ :version: 1.0.0 .. change:: + :tags: bug, tests + :tickets: 3356 + + Fixed the pathing used when tests run; for sqla_nose.py and py.test, + the "./lib" prefix is again inserted at the head of sys.path but + only if sys.flags.no_user_site isn't set; this makes it act just + like the way Python puts "." in the current path by default. + For tox, we are setting the PYTHONNOUSERSITE flag now. + + .. change:: :tags: feature, sql :tickets: 3084 :pullreq: bitbucket:47 diff --git a/regen_callcounts.tox.ini b/regen_callcounts.tox.ini index 056208ca6..e74ceef36 100644 --- a/regen_callcounts.tox.ini +++ b/regen_callcounts.tox.ini @@ -12,8 +12,6 @@ deps=pytest py{27}-sqla_{cext,nocext}-db_{mysql}: mysql-python py{33,34}-sqla_{cext,nocext}-db_{mysql}: pymysql -usedevelop=False -sitepackages=True commands= @@ -22,7 +20,11 @@ commands= db_{postgresql}: {[base]basecommand} --db postgresql {posargs} db_{sqlite}: {[base]basecommand} --db sqlite {posargs} +# -E : ignore PYTHON* environment variables (such as PYTHONPATH) +# -s : don't add user site directory to sys.path; also PYTHONNOUSERSITE setenv= - sqla_nocext: DISABLE_SQLALCHEMY_CEXT=1 + PYTHONPATH= + PYTHONNOUSERSITE=1 + sqla_nocext: DISABLE_SQLALCHEMY_CEXT=1 diff --git a/sqla_nose.py b/sqla_nose.py index fc55f34f7..fe5c4d00b 100755 --- a/sqla_nose.py +++ b/sqla_nose.py @@ -10,10 +10,11 @@ import sys import nose import os - -for pth in ['./lib']: - sys.path.append( - os.path.join(os.path.dirname(os.path.abspath(__file__)), pth)) +if not sys.flags.no_user_site: + sys.path.insert( + 0, + os.path.join(os.path.dirname(os.path.abspath(__file__)), 'lib') + ) # use bootstrapping so that test plugins are loaded # without touching the main library before coverage starts diff --git a/test/conftest.py b/test/conftest.py index 590b35700..36dfaa792 100755 --- a/test/conftest.py +++ b/test/conftest.py @@ -9,10 +9,12 @@ installs SQLAlchemy's testing plugin into the local environment. import sys import os -for pth in ['../lib']: - sys.path.append( - os.path.join(os.path.dirname(os.path.abspath(__file__)), pth)) - +if not sys.flags.no_user_site: + sys.path.insert( + 0, + os.path.join( + os.path.dirname(os.path.abspath(__file__)), '..', 'lib') + ) # use bootstrapping so that test plugins are loaded # without touching the main library before coverage starts @@ -5,8 +5,22 @@ envlist = full,py26,py27,py33,py34 deps=pytest mock -sitepackages=True -usedevelop=True +# -E : ignore PYTHON* environment variables (such as PYTHONPATH) +# -s : don't add user site directory to sys.path; also PYTHONNOUSERSITE +# the latter is picked up by conftest.py +setenv= + PYTHONPATH= + PYTHONNOUSERSITE=1 + +# don't accidentally use a SQLAlchemy that's globally installed during pip; +# unfortunately, without usedevelop, no easy way to use systemwide +# site-packages for dependencies +sitepackages=False + +# always install fully and use that; this way options like +# DISABLE_SQLALCHEMY_CEXT are honored +usedevelop=False + commands= python -m pytest {posargs} |