Path Puzzles

dogboy777 at my-deja.com dogboy777 at my-deja.com
Fri Mar 3 15:41:08 CET 2000


I've started using Steve Purcell's wonderful PyUnit test framework, and I've
run into a problem with paths and modules.  I want to store all of my test
modules, test files,  in a subdirectory.  What that means is that if, for
example, I have a module called command.py and an associated testing module
called tcommand.py, I need to import command. py into tcommand.py. 
tcommand.py needs to know to look for command.py in tcommand.py's parent
directory.

So far, I've kludged the problem by setting PYTHONPATH in DOS before I run
the script from DOS or Linux (we use Samba to map our Win95 clients to our
Linux server).	This works, but it means that every time I create a new
project which will have its own test subdirectory, I've got to change
PYTHONPATH.  There's got to be a better way, right?

The other wierd little problem I ran into was that when I created parser.py
and commands.py, their testing modules freaked and refused to call them: 
self.commands = commands.Commands()  would return an "attribute error:
Commands".  However, when I renamed commands.py to jcommands.py and parser.py
to jparser.py, it worked fine.	Is this because Python already has modules
further up the PYTHONPATH called parser.py and command.py, or did I goof up
in some other way?

Thanks,
Anders Schneiderman
National Journal Daily Briefings
Technology Production Manager


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list