On 05/03/2010 15:56, Antoine Pitrou wrote:
Le Thu, 4 Mar 2010 23:30:12 -0500,
Barry Warsaw<ba...@python.org>  a écrit :
If you really want to test that it's a unicode, shouldn't you
actually test its type?  (I'm not sure what would happen with that
under 2to3.)  Besides, the type of the string is very rarely
important, so I think the u-prefix and quotes is mostly just noise.
String type is actually very important, if you don't want your
application/library to fail in the face of non-ASCII data.

That's why we did all this thing in py3k, after all :)

Well, I'd like to see a 'unicode agnostic' mode for different reasons - although given that it all changes in Python 3 and it is almost certainly too late to get changes to doctest before the 2.7 release the point is probably moot.

IronPython has very different unicode behaviour to Python 2. IronPython is like Python 3 in this regard, all strings are unicode (str is unicode). This means that it rarely puts the u prefix on strings. So doctests that use string repr also fail on IronPython - the django doctest suite is a culprit in this regard too.

Dictionary iteration order is also different in IronPython - so dict reprs also fail. For dict reprs it would be nice if doctest compared in an order agnostic way. (Internally reconstruct the dict as a dict of strings from the repr and then compare using dict equality.)

I know it is easily *possible* to construct doctests that are robust against these differences, but the fact that the "obvious-thing" often fails in subtle ways on other platforms are *one* of the reasons I don't consider doctest to be a suitable tool for unit testing [1]. :-)

Michael

[1] It isn't the main reason and I realise that is entirely orthoganal anway... but doctest makes every line an assertion, and you have to jump through hoops if you don't want that behaviour. All besides the point. Doctest simply *rocks* for testing documentation examples - especially in conjunction with Sphinx.

Regards

Antoine.


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk


--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog

READ CAREFULLY. By accepting and reading this email you agree, on behalf of 
your employer, to release me from all obligations and waivers arising from any 
and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, 
clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and 
acceptable use policies (”BOGUS AGREEMENTS”) that I have entered into with your 
employer, its partners, licensors, agents and assigns, in perpetuity, without 
prejudice to my ongoing rights and privileges. You further represent that you 
have the authority to release me from any BOGUS AGREEMENTS on behalf of your 
employer.


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to