I would recommend the import statements. Then you can paste the doctest 
into Sage and it just works. Thats a big plus IMHO. Explicit is better than 
implicit.



On Thursday, February 2, 2017 at 5:39:58 PM UTC+1, Christian Nassau wrote:
>
> Dear Sage Colleagues, 
>
> The recently merged changes for ticket 20729 have unfortunately broken 
> the doctesting of an external package that I'm working on. A minor 
> nuisance is that symbolic links are apparently no longer resolved, but 
> that is something that I could circumvent (or propose a fix). More 
> serious to me is that I currently see no way to fix my code without 
> littering it with additional import statements: 
>
> suppose I have this structure (starting from sage-root) 
>
>    testpkg/__init__.py 
>
>    testpkg/testfile.py 
>
> where testfile.py is 
>
> ---------------------- 
> """ 
> DOCTEST:: 
>
>     sage: myfunc() 
>     hello 
>
> """ 
>
> def myfunc(): 
>     print "hello" 
>
> ---------------------- 
>
> With 7.6.b1 the command "./sage -t testpkg" no longer imports the file 
> (because of the "__init__.py" in the same directory) and the test fails 
> with "NameError: name 'myfunc' is not defined". 
>
> So my questions, probably, are these: 
>
>    1) is that new behaviour really intended? 
>
>    2) what should/can a package author do to still test his files? 
>
> With regards to 2) it seems I could add an extra "from testpkg.testfile 
> import myfunc" at the beginning of the test, but doing this for all 
> global symbols in every file strikes me as a nightmare solution. Is 
> there maybe a better way to fix this? 
>
> I can also see that the doctesting code checks a certain flag 
> "force_lib" and sage accepts a corresponding "--force_lib" argument for 
> doctesting. Might it be a good idea to add a command line option 
> "--force_code" as the opposite of "--force_lib"? 
>
> Cheers, 
>
> Christian 
>
>
>
>

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

Reply via email to