--- a/pyke/testpyke
+++ b/pyke/testpyke
@@ -13,6 +13,18 @@
 
 PYTHON="python2.5 -Wd"
 
+# Go to pyke directory:
+cd `dirname "$0"`
+
+# Add parent directory to PYTHONPATH:
+parent_dir=$(dirname $(pwd))
+if [ "$PYTHONPATH" ]
+then
+    export PYTHONPATH="$parent_dir:$PYTHONPATH"
+else
+    export PYTHONPATH="$parent_dir"
+fi
+
 if [ $# -ge 2 -a "x$1" = x-p ]
 then
     PYTHON="$2"
@@ -22,6 +34,7 @@
 > $ERRORFILES
 NUM_ERRORS=0
 
+# Do doctests for all .py files (except those generated by pyke):
 for f in `find . -name '*.py' ! -name '*_[bf]c.py'`
 do
     echo Testing "$f"
@@ -32,6 +45,7 @@
     fi
 done
 
+# Check that all of the PLY tables files are up to date:
 cd krb_compiler
 echo Testing scanner_tables.py
 if [ scanner.py -nt scanner_tables.py ]
@@ -54,6 +68,7 @@
     NUM_ERRORS=$(($NUM_ERRORS + 1))
 fi
 
+# Check that the generated krb_compiler/compiler_bc.py file is up to date:
 if [ $NUM_ERRORS -eq 0 ]
 then
     echo Testing compiler.krb
@@ -87,6 +102,7 @@
 
 cd ..
 
+# Final error summary:
 if [ $NUM_ERRORS -eq 0 ]
 then
     echo "No Errors!"