# -*- coding: utf-8 -*
def f(text):
"""
EXAMPLES::
sage: from sage.misc.example import f
sage: s="a=2"
sage: f(s)
'::\n\n sage: a=2'
"""
lines = ['::', '']
prefix=' sage: '
for s in text.splitlines():
lines.append(prefix + s)
return '\n'.join(lines)
And you get a weird error:
File
"/home/moriarty/Software/sage-4.6.1-linux-32bit-ubuntu_10.04_lts-i686-Linux/devel/sage-main/sage/misc/example.py",
line 10:
sage: f(s)
Expected:
'::\n\n sage: a=2'
Got:
'::\n\n sage: a=2'
**********************************************************************
but then make the following simple changes (change prefix from ' sage: '
to ' sag: '):
# -*- coding: utf-8 -*
def f(text):
"""
EXAMPLES::
sage: from sage.misc.example import f
sage: s="a=2"
sage: f(s)
'::\n\n sag: a=2'
"""
lines = ['::', '']
prefix=' sag: '
for s in text.splitlines():
lines.append(prefix + s)
return '\n'.join(lines)
and all tests pass!! They also seem to pass with any prefix that does
not contain the string 'sage:'.
I need to write some tests whose result contain 'sage:': can you help?
Regards
Ah, I see now: we got the same issue with #10652, where the doctest
framework was getting confused by this 'sage:'. As a workaround, you
could probably use something like:
sage: f(s) == '::\n\n sa'+'ge: a=2'
True
Cheers,
Nicolas
--
Nicolas M. Thi�ry "Isil" <nth...@users.sf.net>
http://Nicolas.Thiery.name/