[Python-Dev] doctest, unicode repr, and 2to3

2010-03-04 Thread Martin v. Löwis
Johan Harjano ran into an interesting problem when trying to run the Django test suite under Python 3.1. Django has doctests of the form >>> a6.headline u'Default headline' Even when converting the doctest with 2to3, the expected output is unmodified. However, in 3.x, the expected output will ch

Re: [Python-Dev] doctest, unicode repr, and 2to3

2010-03-04 Thread Barry Warsaw
On Mar 05, 2010, at 05:11 AM, Martin v. Löwis wrote: >Johan Harjano ran into an interesting problem when trying to run the >Django test suite under Python 3.1. > >Django has doctests of the form > a6.headline >u'Default headline' > >Even when converting the doctest with 2to3, the expected out

Re: [Python-Dev] doctest, unicode repr, and 2to3

2010-03-04 Thread Glyph Lefkowitz
On Mar 4, 2010, at 11:30 PM, Barry Warsaw wrote: > 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.) Presumably 2to3 will be smart enough to translate 'unicode' to 'str' and 'bytes' to... 'bytes'. Jus

Re: [Python-Dev] doctest, unicode repr, and 2to3

2010-03-05 Thread Nick Coghlan
Glyph Lefkowitz wrote: > > On Mar 4, 2010, at 11:30 PM, Barry Warsaw wrote: > >> 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.) > > Presumably 2to3 will be smart enough to translate 'unicode' to

Re: [Python-Dev] doctest, unicode repr, and 2to3

2010-03-05 Thread Andrew Bennetts
"Martin v. Löwis" wrote: [...] > Any proposal appreciated. I propose screaming “help me, I have written a test suite using nothing but string matching assertions, what is wrong with me?!” -Andrew. ___ Python-Dev mailing list Python-Dev@python.org http:

Re: [Python-Dev] doctest, unicode repr, and 2to3

2010-03-05 Thread Antoine Pitrou
Le Thu, 4 Mar 2010 23:30:12 -0500, Barry Warsaw 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

Re: [Python-Dev] doctest, unicode repr, and 2to3

2010-03-05 Thread Michael Foord
On 05/03/2010 15:56, Antoine Pitrou wrote: Le Thu, 4 Mar 2010 23:30:12 -0500, Barry Warsaw 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

Re: [Python-Dev] doctest, unicode repr, and 2to3

2010-03-05 Thread Barry Warsaw
On Mar 05, 2010, at 10:56 AM, Antoine Pitrou wrote: >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 :) That's not actually what I mean. I meant that in doctests, you

Re: [Python-Dev] doctest, unicode repr, and 2to3

2010-03-05 Thread Terry Reedy
On 3/4/2010 11:11 PM, "Martin v. Löwis" wrote: Johan Harjano ran into an interesting problem when trying to run the Django test suite under Python 3.1. Django has doctests of the form a6.headline u'Default headline' Even when converting the doctest with 2to3, the expected output is unmodifie

Re: [Python-Dev] doctest, unicode repr, and 2to3

2010-03-05 Thread Martin v. Löwis
Andrew Bennetts wrote: > "Martin v. Löwis" wrote: > [...] >> Any proposal appreciated. > > I propose screaming “help me, I have written a test suite using nothing > but string matching assertions, what is wrong with me?!” Thanks a lot. Regards, Martin

Re: [Python-Dev] doctest, unicode repr, and 2to3

2010-03-05 Thread Guido van Rossum
On Thu, Mar 4, 2010 at 8:11 PM, "Martin v. Löwis" wrote: > Johan Harjano ran into an interesting problem when trying to run the > Django test suite under Python 3.1. > > Django has doctests of the form > a6.headline > u'Default headline' > > Even when converting the doctest with 2to3, the exp

Re: [Python-Dev] doctest, unicode repr, and 2to3

2010-03-05 Thread Martin v. Löwis
> The issue shows (yet again) a general problem with doctests being > overspecified -- the test shouldn't care that the output starts with > 'u', it should only care that the value is unicode, but there's no > easy way to express this in doctests. But since these doctests exist I > suggest that the

Re: [Python-Dev] doctest, unicode repr, and 2to3

2010-03-05 Thread Georg Brandl
Am 05.03.2010 20:37, schrieb Terry Reedy: > On 3/4/2010 11:11 PM, "Martin v. Löwis" wrote: >> Johan Harjano ran into an interesting problem when trying to run the >> Django test suite under Python 3.1. >> >> Django has doctests of the form >> > a6.headline >> u'Default headline' >> >> Even when

Re: [Python-Dev] doctest, unicode repr, and 2to3

2010-03-05 Thread Žiga Seilnacht
Martin v. Löwis wrote: Johan Harjano ran into an interesting problem when trying to run the Django test suite under Python 3.1. Django has doctests of the form >>> a6.headline u'Default headline' Even when converting the doctest with 2to3, the expected output is unmodified. However, in 3.x, th