coverage.py can't find source file

Peter Hansen peter at engcorp.com
Wed Oct 29 18:33:38 EST 2003


Richard Wesley wrote:
> 
> I am using coverage.py to run my unit test suite to check for missing
> tests.  It mostly works, but for some mysterious reason, some of the
> files can't be found because they are not in the same directory as
> configure.py and unit_test.py.  But only SOME of them.
> 
> Anyone have any ideas?

Yes, but probably not the right one.  :-) Anyway, is it possible
that actually *none* of those files are being found, but instead
a bunch of leftover .pyc files in the current directory (or any
other directory that Python can find) are being found?  .pyc files
are as good as .py files to Python, if it can't find the latter.

Also, are you aware of how sys.path is used?  If you check each
directory, starting with the directory in which the main script
is found (and which shows up as '' in sys.path, usually at the start)
for the files, you should be able to find them.  You can also 
try importing one of the files that works, then do 'print module.__file__'
where module is replaced by the right name, and see where the 
files that do work are actually coming from.  It might not be
where you think it is.

Finally, try learning how to use "import pdb; pdb.set_trace()"
which starts an interactive debugger session in the context where
it executes.  Putting this just ahead of the failing imports
would let you interactively debug the problem.

-Peter




More information about the Python-list mailing list