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

List (& dict) comparison tests/fixes #35

Merged

Conversation

ScottFreeCode
Copy link
Contributor

@ScottFreeCode ScottFreeCode commented Sep 5, 2021

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 with quiet = True for the value comparison so types are handled correctly, and list comparison returns False 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).

@ScottFreeCode ScottFreeCode force-pushed the v1.4.0/fix-array-verify branch from 90c367d to 156b884 Compare September 5, 2021 03:30
@ScottFreeCode ScottFreeCode force-pushed the v1.4.0/fix-array-verify branch from 156b884 to 5f0f235 Compare September 5, 2021 03:34
@ScottFreeCode ScottFreeCode force-pushed the v1.4.0/fix-array-verify branch from e378db8 to 766c934 Compare September 5, 2021 03:54
…he number of ANY members must be the same as the number of unmatched actual members
@ScottFreeCode
Copy link
Contributor Author

Threw in tests for ANY in lists for good measure, because I had trouble figuring out whether my list comparison code would handle ANY correctly or if I needed to do anything else for it.

@ScottFreeCode ScottFreeCode marked this pull request as ready for review September 5, 2021 04:08
@ScottFreeCode ScottFreeCode changed the title List comparison tests/fixes List/dict comparison tests/fixes Sep 5, 2021
@ScottFreeCode ScottFreeCode changed the title List/dict comparison tests/fixes List (& dict) comparison tests/fixes Sep 5, 2021
@ScottFreeCode
Copy link
Contributor Author

@shanejansen (Just making sure Github pings you about this PR.)

@shanejansen
Copy link
Owner

@ScottFreeCode Love it! Awesome code and thank you for following existing patterns!

@shanejansen shanejansen merged commit 9d27d34 into shanejansen:release/v1.4.0 Sep 14, 2021
@ScottFreeCode ScottFreeCode deleted the v1.4.0/fix-array-verify branch February 4, 2022 01:09
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

Successfully merging this pull request may close these issues.

2 participants