Hi!
On 24 Jan., 08:22, tvn <[email protected]> wrote:
> I have this file 'myclass.py' that contains the following
>
> class MyClass(object):
> @staticmethod
> def myt(l):
> """
> sage: from myclass import MyClass
> ...
> when run sage -t myclass.py , it gives errors about no module named
> myclass. (details below)
It is known that the doctests won't find modules that are only present
in the "current" directory.
"sage -t myclass.py" first takes myclass.py, extracts the tests,
transforms them into Python format (e.g., replace the "sage:" prompt
by Python's ">>>"), adds some stuff that Python needs to execute the
tests ("from sage import *" or so), and then puts the resulting
temporary file into a temporary directory and performs the tests
*there*.
If I understand that correctly, when Python runs the tests on the
temporary file and executes "from myclass import MyClass" then it
would try to find the module "myclass" in that temporary directory,
but not in the directory in which you have put "myclass.py". In other
words, the "current" directory is not current when the actual tests
are performed on the temporary file.
So, you should provide a fully qualified path in your test, or should
put myclass.py into the Sage library.
Question (perhaps better to sage-devel): It should be possible that
"sage -t myclass.py" finds out the location of myclass.py and adds it
to the Python path - which would probably be enough to solve the
problem. Would that be a reasonable addition to the test framework?
Cheers,
Simon
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org