[pypy-dev] utest conversion

Armin Rigo arigo at tunes.org
Tue Jun 15 18:56:07 CEST 2004


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 :-)


Armin



More information about the Pypy-dev mailing list