[Checkins] SVN: Sandbox/J1m/customdoctests/src/zc/customdoctests/js.py Changed the way text is transformed to make failures look a little
Jim Fulton
jim at zope.com
Tue Feb 1 11:37:45 EST 2011
Log message for revision 120040:
Changed the way text is transformed to make failures look a little
better. (Try to end transformed code with a newline.)
Changed:
U Sandbox/J1m/customdoctests/src/zc/customdoctests/js.py
-=-
Modified: Sandbox/J1m/customdoctests/src/zc/customdoctests/js.py
===================================================================
--- Sandbox/J1m/customdoctests/src/zc/customdoctests/js.py 2011-02-01 16:37:44 UTC (rev 120039)
+++ Sandbox/J1m/customdoctests/src/zc/customdoctests/js.py 2011-02-01 16:37:45 UTC (rev 120040)
@@ -20,13 +20,20 @@
run_time = None
+def transform(s):
+ if s[-1] == '\n':
+ return (r'JS(r"""%s"""+"\n")' % s) + '\n'
+ else:
+ return r'JS(r"""%s""")' % s
+
parser = zc.customdoctests.DocTestParser(
- ps1='js>', transform=lambda s: 'JS(r"""%s""")' % s)
+ ps1='js>', comment_prefix='//', transform=transform)
# parser_ is like parser, except adds: var _ = to
# the fron of the executed code.
eq_parser = zc.customdoctests.DocTestParser(
- ps1='js!', transform=lambda s: 'JS("var _ = "+ r"""%s""")' % s)
+ ps1='js!', comment_prefix='//',
+ transform=lambda s: transform('var _ = ' + s))
def setUp(test_or_self):
globs = getattr(test_or_self, 'globs', test_or_self.__dict__)
More information about the checkins
mailing list