List (& dict) comparison tests/fixes #35
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added explicit test cases for different types being compared in lists: single-value types (string used in practice), lists, and dicts. Test cases cover both "can lists of these be compared" (with just one element) and "can lists of these be compared out of order".
Five of the six cases (used to) fail; only the single dict case passes.
Similarly added tests for cases where the types of dicts' values are different – these were getting delegated to the comparison function for the type of the expected item even if the actual item is a different type. (It is possible that one of the tests might actually pass because the comparison method selected happens to be valid for use against the other type and return False "by accident"; fixing this should guarantee we get correct equals comparison for type mismatches, which should always return False by design.)
Then, added fixes for both – they now delegate to
matches
withquiet = True
for the value comparison so types are handled correctly, and list comparison returnsFalse
if any item in expected does not match any item in actual (otherwise returns True if lengths are the same and all items in expected match an item in actual).