Here is a way to run doctests on gql.py from a web2py dir:
The trick is to put the appengine path on the sys.path and then run the file (gluon/contrib/gql.py). The appengine path will vary based on your platform.
export PYTHONPATH=.:/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine
python gluon/contrib/gql.py