-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Provide an implementation of UnitTest.assertCountEqual #5548
Comments
I don't think pytest should grow an assertion library, you can already get essentially this by using sets or counters (and with better assertion messages usually) |
pytest should grow assertion helpers, something like the "unordered" or a "sorted" object would be helpfull in many ways but this should be started outside of pytest and experimented wtith for a few years before bringing it into core |
Closing this issue, as it's suitable to be demonstrated in a plugin before further discussion in Pytest. |
Has anyone started working on a plugin for this? |
im unaware, if anyone is please link |
Here is a related SO question: https://stackoverflow.com/questions/41605889/does-pytest-have-an-assertitemsequal-assertcountequal-equivalent |
For reference: pytest-dev/pytest-django#709 (using Django's helpers). |
Is a plugin able to inject a function into the |
intentionally no longer |
What hook the plugin should use then? |
@utapyngo well, it needs assertrepr hooks for explaining whats different/not different |
@RonnyPfannschmidt, could you please review pytest-unordered? @software-opal, will this work for you? from pytest_unordered import unordered
def test_reverse_keeps_items():
my_list = ['a', {'key': 'value'}, object()]
assert my_list == unordered(list(reversed(my_list))) |
Currently if I want to test that two lists contain the same elements, ignoring their order, I need to use a set(only on hashable types) or use a
UnitTest
subclass(which means I loose some functionality).It would be good to provide some guidance on how to do within PyTest.
I'm thinking it would look something like this:
If this isn't a good idea it would be nice to add a note in the docs on how to do it so that people can easily discover it.
The text was updated successfully, but these errors were encountered: