[pypy-dev] utest conversion

holger krekel hpk at trillke.net
Tue Jun 15 19:06:45 CEST 2004


[Armin Rigo Tue, Jun 15, 2004 at 05:56:07PM +0100]
> Hi,
> 
> Building on a suggestion by Jacob on how to safely convert old-style unittests
> "self.assertEquals(x,y)" into new-style utest "assert x == y": the difficulty
> is not to find the self.assertEquals() in the test sources, but to safely
> identify the comma between the two arguments, and not mistake it with some
> other comma that could appear in x or in y.
> 
> There was talk about subtle string parsing, or about using Python's parser or
> compiler package, but actually it is much easier than that...  Just try to
> split the text "x,y" between the parenthesis in two halves at every possible
> comma position, until both halves compile without raising SyntaxError :-)

Yes, that reminds me of my favourite "try-parsing" technique (used 
in rlcompleter2 and elsewhere :-) 

Actually you also need to check for multiline-parseability first. IIRC
we do have a quite a bit of multiline-asserts. 

cheers,

    holger



More information about the Pypy-dev mailing list