Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

trouble using import and doctest together

I have a project that contains several .py files that I want to doctest. They are interrelated and each has a few imports that load the dependencies. When I run

sage -t myfile.py

then it says that it can't find the module that myfile wants to import, even though they are in the same directory. If I put

import sys
sys.path.append(".")

at the top of every file, it works fine, provided that I run sage -t from the sage directory. This is a little annoying, is there a better way?