#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
---------------------------------------------------------+------------------
Comment(by jhpalmieri):
Sorry, here's a new version. The relevant changes:
{{{
#!diff
diff --git a/sage-doctest b/sage-doctest
--- a/sage-doctest
+++ b/sage-doctest
@@ -510,8 +510,9 @@ def check_with_tolerance(expected, actua
elif ext in ['.py', '.sage']:
- target_name = "%s_%d" % (file_name, os.getpid()) # like
'name', but unique
- target_base = os.path.join(SAGE_TESTDIR, target_name) # like
'base', also unique
+ root_name = os.path.basename(root_name)
+ target_name = "%s_%d" % (root_name, os.getpid()) # like
'root_name', but unique
+ target_base = os.path.join(SAGE_TESTDIR, target_name) # like
'target_name' but with full path
if ext == '.sage':
# TODO: preparse "<file>.sage" with a Sage library call
@@ -528,7 +529,7 @@ 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
}}}
Changing "source" to "file_name" is necessary: doctesting non-library py
files fails otherwise. The other change is to avoid failures if you
specify a path name for the file to be tested: `sage -t ./test.py` will
fail without this, as compared to `sage -t test.py`.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/8708#comment:10>
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.