#8708: allow doctest script to handle docstrings with triple single quotes
---------------------------------------------------------+------------------
   Reporter:  mvngu                                      |          Owner:  tbd 
         
       Type:  enhancement                                |         Status:  
needs_review 
   Priority:  blocker                                    |      Milestone:  
sage-4.7.2   
  Component:  doctest                                    |       Keywords:      
         
Work_issues:  Rebase on #9739 (and perhaps also 10952).  |       Upstream:  N/A 
         
   Reviewer:  Burcin Erocal                              |         Author:  
John Palmieri
     Merged:                                             |   Dependencies:  
#9739        
---------------------------------------------------------+------------------
Changes (by jhpalmieri):

  * priority:  minor => blocker
  * status:  needs_work => needs_review


Comment:

 We missed an or two issue in #9739: with non-library files, first we just
 had a bug, using "source" instead of "file_name" or "root_name" or
 something.  Second, in the import statement added to the file,
 {{{
 s += "from %s import *\n\n" % target_name
 }}}
 we need to replace `target_name` with `os.path.basename(target_name)`.

 In the new patch, I've made these two changes and also rebased.  Given
 that there is actually new content, this needs a new review.  Without the
 new content, doctesting .py non-library files completely fails, so I'm
 marking this as a blocker.  Feel free to downgrade if you think it's
 appropriate.

 Oh, I also realized that the attached file for testing purposes has a bad
 name: replace the hyphen with an underscore.

 The part needing review:
 {{{
 #!diff
 diff --git a/sage-doctest b/sage-doctest
 --- a/sage-doctest
 +++ b/sage-doctest
 @@ -510,7 +510,7 @@ def check_with_tolerance(expected, actua

          elif ext in ['.py', '.sage']:

 -            target_name = "%s_%d" % (file_name, os.getpid()) # like
 'name', but
 +            target_name = "%s_%d" % (root_name, os.getpid()) # like
 'name', but
              target_base = os.path.join(SAGE_TESTDIR, target_name) # like
 'base'

              if ext == '.sage':
 @@ -528,9 +528,9 @@ def check_with_tolerance(expected, actua
                  # TODO: instead of copying the file, add its source
                  # directory to PYTHONPATH.  We would also have to
                  # import from 'name' instead of 'target_name'.
 -                os.system("cp '%s' %s.py" % (source, target_base))
 +                os.system("cp '%s' %s.py" % (file_name, target_base))

 -            s += "from %s import *\n\n" % target_name
 +            s += "from %s import *\n\n" % os.path.basename(target_name)

              tmpfiles.append(target_base + ".py") # preparsed or copied
 original
              tmpfiles.append(target_base + ".pyc") # compiled version of
 it
 }}}

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/8708#comment:8>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
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-trac?hl=en.

Reply via email to