#8708: allow doctest script to handle docstrings with triple single quotes
---------------------------+------------------------------------------------
Reporter: mvngu | Owner: tbd
Type: enhancement | Status: needs_review
Priority: minor | Milestone: sage-4.7.2
Component: doctest | Keywords:
Work_issues: | Upstream: N/A
Reviewer: | Author: Burcin Erocal, John Palmieri
Merged: | Dependencies:
---------------------------+------------------------------------------------
Comment(by jhpalmieri):
Oh, you're right. I'm replacing my patch with a new one, the difference
being
{{{
#!diff
diff --git a/sage-doctest b/sage-doctest
--- a/sage-doctest
+++ b/sage-doctest
@@ -452,8 +452,10 @@ def change_warning_output(file):
tmpfiles.append(os.path.join(SAGE_TESTDIR, name + '.pyc'))
# Prefix/suffix for all doctests replacing the starting/ending """
- doc_prefix = 'r""">>> set_random_seed(0L)\n\n>>>
change_warning_output(sys.stdout)\n\n'
- doc_suffix = '\n>>> sig_on_count()\n0\n"""'
+ doc_prefix_dq = 'r""">>> set_random_seed(0L)\n\n>>>
change_warning_output(sys.stdout)\n\n'
+ doc_prefix_sq = doc_prefix_dq.replace('"""',"'''")
+ doc_suffix_dq = '\n>>> sig_on_count()\n0\n"""'
+ doc_suffix_sq = doc_suffix_dq.replace('"""',"'''")
n = 0
# Now extract the docstring by using a regular expression search
@@ -499,7 +501,10 @@ def change_warning_output(file):
name = "example"
s += "def %s_%s():"%(name,n_str)
n += 1
- s += "\t"+ doc_prefix + doc + doc_suffix + "\n\n"
+ if m.groups()[0].find("'") > -1: # single quotes
+ s += "\t"+ doc_prefix_sq + doc + doc_suffix_sq + "\n\n"
+ else:
+ s += "\t"+ doc_prefix_dq + doc + doc_suffix_dq + "\n\n"
if n == 0:
return ''
}}}
I'll also add an example like this to the testing file.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/8708#comment:4>
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.