[PATCH 1 of 1] tests: asciify output of tsttest
Martin Geisler
mg at lazybytes.net
Sun Sep 19 09:14:23 CDT 2010
Yuya Nishihara <yuya at tcha.org> writes:
>> I didn't know that encoding. It seems like that encoding is defined as
>> eval("'" + x.encode('string-escape') + "'") == x
>> and it will thus always escape '.
>>
>> An alternative is to use repr(x)[1:-1] which only will escape ' if
>> the string also contains ".
>>
>> It probably doesn't matter.
>>
>> BUT if you use string-escape then there is probably no reason to use
>> regexps first and it is probably faster to always just string-escape.
>> And then there is no need to define an asciify function at all.
>
> It'll be simple if we can just write s.encode('string-escape') or
> repr(s)[1:-1] without re.sub(), but it's necessary to avoid unwanted
> escapes like \t, \n, \'.
I think the simplest way is to use
s.encode('string-escape').replace(r'\'', '\'').replace(r'\n', '\n')
That makes it very explicit what is going on.
>> I think that with this patch in place tests/printrepr.py should go
>> away. I'm not sure if it should be done in the same patch or in
>> another.
A new patch, please. This patch is already touching a lot of files and
removing printrepr.py would be a related by different change.
> After all test cases are migrated to tsttest?
> Currently shell-based tests use printrepr.py.
Ah, then we'll wait till they are all migrated.
--
Martin Geisler
Mercurial links: http://mercurial.ch/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20100919/aa18c11b/attachment.pgp>
More information about the Mercurial-devel
mailing list