Skip to content

Add comprehensive tests for MultiDict.__eq__ vs different types#76

Merged
gerlero merged 4 commits intomainfrom
copilot/fix-6c2ebf27-e2a1-4e7b-8043-8fdccb4dbee4
Sep 6, 2025
Merged

Add comprehensive tests for MultiDict.__eq__ vs different types#76
gerlero merged 4 commits intomainfrom
copilot/fix-6c2ebf27-e2a1-4e7b-8043-8fdccb4dbee4

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 6, 2025

Adds comprehensive test coverage for the MultiDict.__eq__ method against various types as requested in the issue. The new test function test_multidict_equality() validates equality comparisons with:

Test Coverage

MultiDict vs MultiDict: Tests same content, different content, and different order scenarios, including empty instances.

MultiDict vs multidict.MultiDict: Ensures compatibility with the external multidict library's MultiDict implementation, testing both matching and non-matching content/order.

MultiDict vs other MultiMappings: Tests against ListMultiDict (the minimal implementation used in tests) to verify the MultiMapping comparison logic.

MultiDict vs regular dicts: Validates the special dict comparison logic that checks all MultiDict items against dict values, including edge cases with duplicate keys and length mismatches.

MultiDict vs non-mapping types: Verifies that __eq__ correctly returns NotImplemented for non-mapping types (strings, integers, lists, None), while the == operator ultimately returns False.

Key Behaviors Tested

  • Order sensitivity: MultiDict comparisons with other MultiMappings respect item order
  • Length checking: Dict comparisons fail fast on length mismatch
  • Duplicate key handling: Dict comparisons require ALL MultiDict items to match the corresponding dict value
  • NotImplemented protocol: Proper handling of non-mapping types
  • Edge cases: Empty containers, special values (None, 0, ""), KeyError scenarios

The tests ensure the equality implementation behaves correctly across all supported comparison types while maintaining backward compatibility.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: gerlero <15150530+gerlero@users.noreply.github.com>
Copilot AI changed the title [WIP] Add test for MultiDict.__eq__ vs. other types (other MultiDicts, multidict.MultiDicts, other MultiMappings, dicts) Add comprehensive tests for MultiDict.__eq__ vs different types Sep 6, 2025
Copilot AI requested a review from gerlero September 6, 2025 14:45
Copy link
Copy Markdown
Owner

@gerlero gerlero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Thanks!

@gerlero gerlero marked this pull request as ready for review September 6, 2025 14:55
@gerlero gerlero merged commit 803c32c into main Sep 6, 2025
12 checks passed
@gerlero gerlero deleted the copilot/fix-6c2ebf27-e2a1-4e7b-8043-8fdccb4dbee4 branch September 6, 2025 14:55
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