[Grok-dev] how to write doctest in unicode?
ct at gocept.com
Sun Aug 31 06:09:08 EDT 2008
On Sat, 2008-08-30 at 05:04 +0200, Uli Fouquet wrote:
> Hi Brandon,
> Brandon Craig Rhodes wrote:
> > I am attempting to write a doctest file by creating a .txt file and
> > putting ":Test-Layer: unit" up at the top, as outlined in:
> > http://grok.zope.org/documentation/how-to/tests-with-grok-testing
> > But I cannot figure out how to make it Unicode-friendly; I am getting
> > mismatch reports like:
> > - u'1¼ years'
> > ? ^^
> > + u'1\xbc years'
> > ? ^^^^
> > Is there something like an ":Encoding: utf-8" that I can put at the top
> > of my doctest to get things working?
Warning: Road bumps ahead.
If you encode your doctest in anything besides ASCII, then distutils
will break when registering with PyPI (in case that this doctest is
going to show up there).
As your Python interpreter already pointed you to it. You can also write
this in your code/expectation:
This allows you to represent unicode characters embedded in an ASCII
document. It's not as readable but works.
Side note: for me, doctests that didn't go to PyPI I experienced the
encoding to be latin1 by default (without me knowing how to change it).
Christian Theune · ct at gocept.com
gocept gmbh & co. kg · forsterstraße 29 · 06112 halle (saale) · germany
http://gocept.com · tel +49 345 1229889 7 · fax +49 345 1229889 1
Zope and Plone consulting and development
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://mail.zope.org/pipermail/grok-dev/attachments/20080831/f1ddae8c/attachment.bin
More information about the Grok-dev