[PATCH] Behave better when PYTHONPATH is already set
David Shea
dshea at redhat.com
Wed Sep 18 19:16:51 UTC 2013
Append to $PYTHONPATH rather than replacing it. Use $top_srcdir rather
than $PYTHONPATH to detect whether automake has already set up the test
environment.
---
tests/nosetests.sh | 9 +++------
tests/pylint/runpylint.sh | 10 +++++-----
tests/testenv.sh | 8 ++++++--
3 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/tests/nosetests.sh b/tests/nosetests.sh
index 1ad86c0..e0b1c1e 100755
--- a/tests/nosetests.sh
+++ b/tests/nosetests.sh
@@ -1,11 +1,8 @@
#!/bin/sh
-# Use the directory above the one containing the script as the default for
-# $top_srcdir
-: "${top_srcdir:=$(dirname "$0")/..}"
-
-# If no PYTHONPATH is set, import the test environment
-if [ -z "$PYTHONPATH" ]; then
+# If $top_srcdir has not been set by automake, import the test environment
+if [ -z "$top_srcdir" ]; then
+ top_srcdir="$(dirname "$0")/.."
. ${top_srcdir}/tests/testenv.sh
fi
diff --git a/tests/pylint/runpylint.sh b/tests/pylint/runpylint.sh
index 6fe1b6c..af4183e 100755
--- a/tests/pylint/runpylint.sh
+++ b/tests/pylint/runpylint.sh
@@ -15,14 +15,14 @@ if [ -z "$top_srcdir" ]; then
pylint_log=1
fi
-: "${top_srcdir:=$(dirname "$0")/../..}"
-srcdir="${top_srcdir}/tests/pylint"
-
-# If no PYTHONPATH is set, import the test environment
-if [ -z "$PYTHONPATH" ]; then
+# If $top_srcdir has not been set by automake, import the test environment
+if [ -z "$top_srcdir" ]; then
+ top_srcdir="$(dirname "$0")/../.."
. ${top_srcdir}/tests/testenv.sh
fi
+srcdir="${top_srcdir}/tests/pylint"
+
FALSE_POSITIVES="${srcdir}"/pylint-false-positives
# W0212 - Access to a protected member %s of a client class
diff --git a/tests/testenv.sh b/tests/testenv.sh
index b4749b4..1568644 100644
--- a/tests/testenv.sh
+++ b/tests/testenv.sh
@@ -5,10 +5,14 @@ if [ -z "$top_srcdir" ]; then
exit 1
fi
-# If not top_builddir is set, use top_srcdir
+# If no top_builddir is set, use top_srcdir
: "${top_builddir:=$top_srcdir}"
-PYTHONPATH="${top_builddir}/pyanaconda/isys/.libs:${top_srcdir}/pyanaconda:${top_srcdir}"
+if [ -z "$PYTHONPATH" ]; then
+ PYTHONPATH="${top_builddir}/pyanaconda/isys/.libs:${top_srcdir}/pyanaconda:${top_srcdir}"
+else
+ PYTHONPATH="${PYTHONPATH}:${top_builddir}/pyanaconda/isys/.libs:${top_srcdir}/pyanaconda:${top_srcdir}"
+fi
export PYTHONPATH
export top_srcdir
export top_builddir
--
1.8.3.1
More information about the anaconda-patches
mailing list