I have two .py files (not in the library) in the same directory where one
imports the other. I'd like to run doctests, but the local directory does not
seem to be in the search path. Is there any way of doing this apart from
fiddling around with sys.path in the .py files themselves?

##
Advertising

Minimal example:
b.py
====
"""
EXAMPLES::
sage: bar()
Bar
"""
def bar():
print "Bar"
====
a.py
====
"""
EXAMPLES::
sage: foo()
Foo
sage: bar()
Bar
"""
from b import bar
def foo():
print "Foo"
====
$ sage -t .
too many failed tests, not using stored timings
Running doctests with ID 2016-09-20-13-38-33-1ca61f3e.
Using --optional=ccache,mpir,python2,sage
Doctesting 2 files.
sage -t a.py
ImportError in doctesting framework
**********************************************************************
Traceback (most recent call last):
File
"/local/sage/sage-7.3/local/lib/python2.7/site-packages/sage/doctest/forker.py",
line 2128, in __call__
doctests, extras = self.source.create_doctests(sage_namespace)
File
"/local/sage/sage-7.3/local/lib/python2.7/site-packages/sage/doctest/sources.py",
line 670, in create_doctests
load(filename, namespace) # errors raised here will be caught in DocTestTask
File
"/local/sage/sage-7.3/local/lib/python2.7/site-packages/sage/repl/load.py", line
271, in load
exec(code, globals)
File "./a.py", line 13, in <module>
from b import bar
ImportError: No module named b
sage -t b.py
[1 test, 0.00 s]
----------------------------------------------------------------------
sage -t a.py # ImportError in doctesting framework
----------------------------------------------------------------------
Total time for all tests: 0.0 seconds
cpu time: 0.0 seconds
cumulative wall time: 0.0 seconds
====
When I add
import sys
sys.path.append(".")
to a.py, it works; but I'd prefer not to have to modify a.py.
Thank you,
Clemens
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.