This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Julian
Recipients Julian
Date 2012-09-20.18:43:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1348166637.22.0.281544835659.issue15987@psf.upfronthosting.co.za>
In-reply-to
Content
As is, as far as I can tell, there's no way to easily compare two AST nodes to see if they have the same children and same fields (recursively).

I'm writing some unit tests for a NodeTransformers, so I've settled for comparing `ast.dump()`s of each, which is kind of dirty, but 1) works and 2) produces reasonable failure messages. (As a side note of what else I've tried, comparing, say, a list of the `iter_child_nodes` is not a good alternative, since the tests I'm writing are making assertions that a given node was not modified, which means they deepcopy the node and then want to assert that the "transformed" node is unchanged.)

I don't know the global implications of changing ast.AST.__eq__ to know if that's feasible (hopefully someone will comment on that), but if it isn't, another provided way would be nice.
History
Date User Action Args
2012-09-20 18:43:57Juliansetrecipients: + Julian
2012-09-20 18:43:57Juliansetmessageid: <1348166637.22.0.281544835659.issue15987@psf.upfronthosting.co.za>
2012-09-20 18:43:56Julianlinkissue15987 messages
2012-09-20 18:43:56Juliancreate