1

I have a pylons project with an extensive set of functional tests that I want my manual QA's to be able to read from time to time, so I'm using epydoc to build out the html pydocs on the functional test modules.

It seems to be working fine. It generates the docs, and I can navigate through them without any apparent problems.

However, I'm getting a strange error when I run the epydoc build, and I'm not sure how to fix it:

+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| In project.tests.functional.resource:
| Import failed (but source code parsing was successful).
|     Error: KeyError: '__file__' (line 28)
|
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | In /Eclipse/product/project/server/src/project/tests/functional/resource/ftest_module1.py: | Import failed (but source code parsing was successful). | Error: KeyError: '__file__' (line 28) |
+------------------------------------------------------------------------------------------

There are a total of 2 packages and 8 modules on which this is happening. I thought at first, it might be the absence of docstrings at the head of the modules, or in the __init__ of the packages, but adding them did not fix it.

Here is a copy of the epydoc config file written specifically for the function tests:

[epydoc]
modules: project.tests.functional.resource,project.tests.functional.views
output: html
sourcecode: yes
#graph: none
target: ../pydoc/ftests
name: PROJECT
# exclude: test
private: no
imports: no
verbosity: 0
include-log: yes

And here is a copy of the shell script used to execute it:

#!/usr/bin/env bash
basedir=${0%/*}
cd "$basedir/../src"

etc="../etc"
pydoc="../pydoc"
pydoc_ftests="../pydoc/ftests"

mkdir -p $pydoc
mkdir -p $pydoc_ftests

epydoc -v --config $etc/epydoc.config
epydoc -v --config $etc/epydoc.ftests.config

Any suggestions?

Greg Gauthier
  • 1,336
  • 1
  • 12
  • 25
  • What is the command line of the epydoc call? – AndiDog Oct 29 '10 at 20:02
  • Oh yes, sorry. I should have included all that. I'll tack it on to the original question... – Greg Gauthier Oct 29 '10 at 20:04
  • Try module paths instead of dotted module names. – AndiDog Oct 29 '10 at 20:17
  • That doesn't seem to have made a difference. I turned up the logging verbosity, and got this near the top: Info: Unable to find base webtest.TestApp but I know the webtest module is available and that the TestApp imports are working, because the build itself succeeds. – Greg Gauthier Oct 29 '10 at 21:28
  • What's the directory structure? Is the webtest module a globally accessible module or does it belong to the project? If you have multiple project module paths that need to be accessed, you might need to override PYTHONPATH for the epydoc call. – AndiDog Oct 30 '10 at 22:05
  • webtest is part of the pylons/paste WSGI testing functionality. The egg name for it is WebTest and the version I'm running is 1.1, for python 2.6. I modified the run script to append WebTest to the PYTHONPATH as follows: "/usr/local/lib/python2.6/dist-packages/WebTest-1.1-py2.6.egg", and I verify that the python interpreter instance under this script has it sourced: python -c "import sys;print 'Webtest is in PYTHONPATH at position: ', sys.path.index('/usr/local/lib/python2.6/dist-packages/WebTest-1.1-py2.6.egg')". I shows up at position 39. But i'm still seeing both errors... – Greg Gauthier Nov 01 '10 at 22:50
  • No clue what's happening. Are you using the latest epydoc version (3.0.1)? BTW people won't get notifications if you don't use the @username syntax when responding to comments. – AndiDog Nov 02 '10 at 19:04
  • @AndiDog wasn't aware of that. Thanks for the tip! To answer your question: $ epydoc --version\n Epydoc, version 3.0.1\n Its not actually preventing the generation of pydoc, so I'm not too concerned. I'm just a little OCD about error messages, I guess... ;) – Greg Gauthier Nov 02 '10 at 19:09
  • I've never seen that problem before. You should trace back where exactly the `Error` and `KeyError` exceptions are raised (in epydoc *or* in your code?) if you're really interested in finding out what this is about. I can't reproduce this unfortunately. – AndiDog Nov 02 '10 at 19:54
  • @AndiDog Apologies for not getting back sooner. What I ended up doing, finally, was just including --parse-only on the epydoc command, to force it not to import anything (thus working around the problem of unlocatable imports, but not really answering why it was happening at all). – Greg Gauthier Jan 06 '11 at 16:14

1 Answers1

0

What I ended up doing, finally, was just including --parse-only on the epydoc command, to force it not to import anything (thus working around the problem of unlocatable imports, but not really answering why it was happening at all). Not a perfect solution, but it satisfied the requirements...

Greg Gauthier
  • 1,336
  • 1
  • 12
  • 25