I'm having some trouble doctesting non sage files. The only things I
could find in the Programming Guide were:

  4.3.1 Testing .py, .pyx and .sage Files

     Run sage -t <filename.py> to test that all code examples in
     filename.py. Similar remarks apply to .sage and
     .pyx files.

and

  5.3.8 Doctests

     If x.pyx is a Cython file, then you can do

      sage -t x.pyx

     to test all the examples in the documentation strings in x.pyx.

But this does not seem to be sufficient. One question: what about
.spyx files? Here is an experiment done on version 2.10.1 that shows
that some clarification (if not some coding) is desirable:

Create a file hello.py with contents:

  def hello():
      """
      Return a friendly string.

      EXAMPLES:
      sage: hello()
      Goodbye!
      """
      return 'Hello!'

Make copies of the file called

  hello.sage
  hello.pyx
  hello.spyx

and then run the commands

  $ sage -t hello.sage  # reports correctly that 'Hello' is not
'Goodbye'
  $ sage -t hello.py    # NameError: name 'hello' is not defined
  $ sage -t hello.pyx   # NameError: name 'hello' is not defined
  $ sage -t hello.spyx  # blithely reports incorrectly that all tests
pass

Following a hint in the Programming Guide, in the case of hello.py,
after changing the EXAMPLES section so it reads

  EXAMPLES:
  sage: from hello import *
  sage: hello()
  Goodbye!

the correct behaviour is recovered. Applying the same change to
hello.pyx is not the right thing to do, since the import will grab the
function out of the module hello.py. However, after changing the name
of the file to hello2.pyx and the function to hello2, we encounter
the same NameError.

Kate
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to