Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add comparison method to Element class? #214

Closed
jacobwhall opened this issue Jun 14, 2022 · 2 comments
Closed

Add comparison method to Element class? #214

jacobwhall opened this issue Jun 14, 2022 · 2 comments

Comments

@jacobwhall
Copy link
Contributor

I have been writing tests for a panflute filter, and thinking about how to best validate its output. While the "batteries included" functions like convert_text() are helpful for this task, I would like to directly compare elements. I suggest that we add a __eq__() comparison method to the pf.Element class that verifies that they are identical both in type and in terms of their parameters.

For example, comparing two pf.Doc elements would check that both have identical block sequences, metadata, format, and API version.

assert pf.Doc == pf.Doc # succeeds only if all parameters are identical

Thank you for your consideration!

@sergiocorreia
Copy link
Owner

Just added this method. I also added a test suite, but haven't tested for correctness as much as I would have liked. So if you spot anything off definitely let me know!

@jacobwhall
Copy link
Contributor Author

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants