[issue11302] Add more tests to test_ast.py

Benjamin Peterson report at bugs.python.org
Mon Jun 27 17:09:58 CEST 2011


Benjamin Peterson <benjamin at python.org> added the comment:

2011/6/27 Vincent Legoll <report at bugs.python.org>:
>
> Vincent Legoll <vincent.legoll at gmail.com> added the comment:
>
> I was testing exact matches on the strings because I think pypy wants to be as compliant as possible with cpython, and IMHO that include exception msgs as far as possible. I don't see any reason to be different just for the sake of it.

It's not difference just for the sake of it. Exact compatibility with
errors messages is not particularly useful as long as they have the
same semantic meaning.

>
> As a user I'd find strange not to get same exc msgs from different implementations, and it'll make me loose some time digging why those difference exist...

The usually mean the same thing; they're just worded differently.

>
> Back to the patch:
>
> The multiline (and also differing offsets) are there for testing .lineno & .col_offset AST node's attributes. (there was a bug in pypy's implementation of those back then...)
>
> Do you want that explained in the comment ?
>
> Do you want me to add "self.assertIn("foobar", str(e))" in the tests, remove the comments or let them as in the patch #2 ?

If you want, you can test the exc message with the assertIn pattern.

I don't find there's much potential for mistaking where the attribute
error is in "x.not_an_attribute". :)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11302>
_______________________________________


More information about the Python-bugs-list mailing list