From: Mike Bayer Date: Sat, 4 Apr 2015 23:08:18 +0000 (-0400) Subject: - Fixed the pathing used when tests run; for sqla_nose.py and py.test, X-Git-Tag: rel_1_0_0~16 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f30e35babc63f5613537bb62aef6acb26dadd503;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - 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 --- diff --git a/doc/build/changelog/changelog_10.rst b/doc/build/changelog/changelog_10.rst index 7b101389d2..6f2e1542b4 100644 --- a/doc/build/changelog/changelog_10.rst +++ b/doc/build/changelog/changelog_10.rst @@ -18,6 +18,16 @@ .. changelog:: :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 diff --git a/regen_callcounts.tox.ini b/regen_callcounts.tox.ini index 056208ca67..e74ceef362 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 fc55f34f78..fe5c4d00bc 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 590b357005..36dfaa7926 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 diff --git a/tox.ini b/tox.ini index 3b1d2eae55..8cd41908c6 100644 --- a/tox.ini +++ b/tox.ini @@ -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}