Hi Pablo! On Fri, Apr 08, 2011 at 11:17:12AM +0200, Pablo Angulo wrote: > I've found a very weird error trying to get some files pass the > automated testing: I got the same "Expected" and "Got", but the test > failed. Copy the following text to devel/sage/sage/misc/example.py: > > # -*- 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?
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" <nthi...@users.sf.net> http://Nicolas.Thiery.name/ -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org