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?
You mean: You have, myfile.py containing a test with "sage: from myotherfile import f", and you have myotherfile.py containing the definition of f? Then the import works if you do it in a sage session, but not when you do it in "sage -t myfile.py"? That's a good question that I'd like to know the answer of, myself!
yes, that is right. Or if I have "from myotherfile import g" just listed at the top of myfile, it also doesn't work.
yes, that is right. Or if I have "from myotherfile import g" just listed at the top of myfile, it also doesn't work.