Opened 3 years ago

Closed 3 years ago

#6848 enhancement closed fixed (fixed)

twisted.names.dns.Messages should be compared based on their field values and section contents

Reported by: rwall Owned by: tom.prince
Priority: normal Milestone:
Component: names Keywords:
Cc: Branch: branches/rich-message-comparison-6848
branch-diff, diff-cov, branch-cov, buildbot
Author: rwall


Some twisted.names tests would be much easier to write if dns.Message implemented some of the rich comparison methods and if the Messages were compared based on their field values and section contents.

The simplest way to do this is to inherit from FancyEqMixin.

Which is what we've don in the proposed EDNSMessage class in #5675


And see #6847 where I've added FancyStrMixin for a nicer Message repr.

Change History (4)

comment:1 Changed 3 years ago by rwall

  • Author set to rwall
  • Branch set to branches/rich-message-comparison-6848

(In [40844]) Branching to 'rich-message-comparison-6848'

comment:2 Changed 3 years ago by rwall

  • Keywords review added

Ready for review in log:branches/rich-message-comparison-6848

  • Added FancyEqMixin and associated tests
  • This and #6847 should allow some shared rich comparison tests between dns.Message and dns.EDNSMessage in #5675
  • Not sure how adding rich comparison and repr fits in with the compatibility policy.
  • It would be nice if showAttributes and compareAttributes could be private, that'll require a change to FancyEq and FancyStrMixin. Good idea?

Build Results:

comment:3 Changed 3 years ago by tom.prince

  • Keywords review removed
  • Owner set to tom.prince

This looks good. I'll merge it. I reordered the attributes and tests to match the constructor argument order, to make it easier to review.

comment:4 Changed 3 years ago by tomprince

  • Resolution set to fixed
  • Status changed from new to closed

(In [40930]) Merge rich-message-comparison-6848: Compare twisted.names.dns.Messages based on its attributes.

Author: rwall Reviewers: tom.prince Fixes: #6848

Some twisted.names tests will be much easier to write if dns.Message has a value based equality, rather than object identity based equality.

Note: See TracTickets for help on using tickets.