Hi Simon,

On Mon, 17 Nov 2008 11:26:16 -0800 (PST)
Simon King <[EMAIL PROTECTED]> wrote:

> 
> Dear Team,
> 
> I have a couple of .pyx files and (sometimes trying to be a good boy)
> I provided long doc strings with lots of doc tests.

I do this with the code I develop out of the tree too. You need to
import your module explicitly for each doctest, i.e., include a "from
foo import func_name" at the beginning of your EXAMPLES: section. 

However, this didn't work properly until recently, since the
sage-doctest script didn't add the contents of the SAGE_PATH variable
to sys.path.

A patch fixing this is in 3.2.rc1, but I don't recall if it was in a
previous stable release or not. Which version are you using?

> However,
>    sage -t foo.pyx
> fails by raising errors on *all* tests that involve any function from
> 'foo.pyx'.

> First attempt:
>   Plainly use the function 'bar' from 'foo.pyx'
>   Result: NameError: name 'bar' is not defined

This is not expected to work.

> Second attempt:
>   Import 'foo' in all examples (there is 'foo.so' in the directory)
>   Result: ImportError: No module named foo

But this should.
 
> Third attempt:
>   Explicitly name the function 'foo.bar'.
>   Result: NameError: name 'foo' is not defined
> 
> The puzzling fact is: The test examples work if I try them directly in
> Sage after doing
>   from foo import *

Sage seems to include the current directory in the module search path
(sys.path). This is not the case for doctesting. I think using the
SAGE_PATH variable in general is a better approach.

Cheers,

Burcin

--~--~---------~--~----~------------~-------~--~----~
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