Hi! On 21 Apr., 18:23, tvn <[email protected]> wrote: > Hi, sorry I still don't get this. > > If I write my code in a test.sage file -- then load or attach it from Sage > interactive. Then how do I call doctest on it ? Previously I write my > code in a test.py file , then from Sage interactive session I call import > test , then doctest.testmod(test) .
Sage code can be tested like sage -t path/to/your/file.py (on the command line). There are further variations such as "sage -t - long" or "-optional" or "-verbose". See http://www.sagemath.org/doc/developer/doctesting.html Moreover, ">>> " is the Python prompt. You should use the Sage prompt "sage: " in your tests. Just look into some doc strings, you'll easily get the syntax. > Also if all my development is in Sage, then the preferred method is writing > code in .sage instead .py ? No. The preferred method is to use .py (resp. .pyx if you write in Cython). @Justin: When I wrote my first reply, I had to leave within minutes. So, I simply had no time for tests. But it is very obvious that using a .py file can not be the problem (or there would be no .py files in the Sage library). So, my reply was not really hypothetical. Best regards, 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
