doctesting

Ben Artin macdev at artins.org
Tue Jan 2 04:33:16 EST 2007


In article <mailman.2196.1167726381.32031.python-list at python.org>,
 belinda thom <bthom at cs.hmc.edu> wrote:

> I'd like to write a tester script that I can place in one place (say  
> ~/bin/python/tester.py) and then have it visible to me at the cmd- 
> line (by setting the path  variable appropriately). I have had no  
> luck in getting it to work, however.
> 
> It appears like the doctest code itself assumes that all modules to  
> be imported lie in some directory other than the one I invoked the  
> tester.py script from. In particular, simple imports in a .txt file  
> like:
> 
>    >>> import foo
> 
> fail even though I've started the script in a directory that contains  
> file foo.py

import foo looks at sys.path which is based on PYTHONPATH in the environment. 
So, one way to do what you want is to have your script modify sys.path before 
importing other modules.

hth

Ben

-- 
If this message helped you, consider buying an item
from my wish list: <http://artins.org/ben/wishlist>

I changed my name: <http://periodic-kingdom.org/People/NameChange.php>



More information about the Python-list mailing list