-if [ -f ./bin/nosetests ]; then
- echo "Using ./bin/nosetests";
- export NOSETESTS="./bin/nosetests";
+basedir="`dirname $0`"
+# Directory to seaerch for:
+subdir="mediagoblin/tests"
+[ '!' -d "$basedir/$subdir" ] && basedir="."
+if [ '!' -d "$basedir/$subdir" ]
+then
+ echo "Could not find base directory" >&2
+ exit 1
+fi
+
+if [ -x "$basedir/bin/nosetests" ]; then
+ export NOSETESTS="$basedir/bin/nosetests";
+ echo "Using $NOSETESTS";