mwilliamson / python-precisely

Matcher library for Python
BSD 2-Clause "Simplified" License
238 stars 11 forks source link

Add mapping_includes matcher #13

Closed ErwinJunge closed 5 years ago

ErwinJunge commented 5 years ago

This adds a matcher called is_mapping_with to allow partial dict matches (i.e. allow extra keys).

ErwinJunge commented 5 years ago

FYI: the travis errors are not related to the code changes in this PR, they have something to do with travis setting up py32 and py33.

mwilliamson commented 5 years ago

Thanks for the pull request. Rebasing onto master should fix the Python 3.2 and 3.3 errors (by dropping support).

I'm not sure the naming of the function is very clear. We already have an includes() function for iterables. Perhaps mapping_includes would be clearer?

ErwinJunge commented 5 years ago

Thanks for the pull request. Rebasing onto master should fix the Python 3.2 and 3.3 errors (by dropping support).

I'm not sure the naming of the function is very clear. We already have an includes() function for iterables. Perhaps mapping_includes would be clearer?

Rebased. The naming ties into https://github.com/mwilliamson/python-precisely/pull/14 where I introduce is_sequence_with (which is subtly different from includes)

mwilliamson commented 5 years ago

I'm not sure is_sequence_with() is the right name in the other pull request ("with" doesn't imply the subsetting behaviour to me), and this feels closer to includes() than is_sequence_with() since this doesn't care about ordering.

mwilliamson commented 5 years ago

Thanks! I've merged this, and made a couple of minor tweaks to the implementation.