Skip to content

Commit

Permalink
- Fixed the pathing used when tests run; for sqla_nose.py and py.test,
Browse files Browse the repository at this point in the history
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
  • Loading branch information
zzzeek committed Apr 4, 2015
1 parent ecd7b31 commit f30e35b
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 13 deletions.
10 changes: 10 additions & 0 deletions doc/build/changelog/changelog_10.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions regen_callcounts.tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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


9 changes: 5 additions & 4 deletions sqla_nose.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
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
Expand Down
10 changes: 6 additions & 4 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
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
Expand Down
18 changes: 16 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit f30e35b

Please sign in to comment.