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: Richard Wall 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

Description

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

See https://twistedmatrix.com/trac/browser/branches/edns-message-5675-4/twisted/names/dns.py?rev=40240#L2228

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

Change History (4)

comment:1 Changed 3 years ago by Richard Wall

Author: rwall
Branch: branches/rich-message-comparison-6848

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

comment:2 Changed 3 years ago by Richard Wall

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 Tom Prince

Resolution: fixed
Status: newclosed

(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.