trouble with unittest and namespaces - can anyone help?

Lol McBride lol at lolmc.nospam.com
Wed Nov 12 03:20:12 EST 2003


On Tue, 11 Nov 2003 18:55:16 -0500, Peter Hansen wrote:
<< snip snip >>
> Given that your tests are in a subfolder of the one where prog2.py
> is found, I'm not sure how you are invoking the tests right now 
> such that they are working at all.  How do they find "prog2"
> when they import it right now?
> 
> -Peter
Yes Peter you're right I did mean sys.path.
I use some code from a tutorial in Linux Format magazine to get the test
in the subfolder to work as below:
import unittest
# Import from this modules parent directory
import os
import sys
sys.path.insert(0,os.pardir)
import BallLoop
del sys.path[0]
del sys
del os

Could you expand a little on your answer - perhaps using the structure I
used as an example?I tend to need a bit of hand-holding till I understand
the gist of what I'm shown.
Thanks
Lol ;-)




More information about the Python-list mailing list