Opened 10 years ago

Last modified 10 years ago

#3745 enhancement new

t.names.client.Resolver maybeParseConfig should be optional to ease testing

Reported by: ivank Owned by: ivank
Priority: low Milestone:
Component: names Keywords:
Cc: Branch:
Author:

Description

If it is made optional, tests that somehow use t.names.client.Resolver can monkey-patch _resolvReadInterval to get rid of delayed calls.

Even if monkey-patching is evil, at least there is less stuff to override in the case that someone doesn't want to maybeParseConfig.

Attachments (1)

t.names.client.Resolver_maybeParseConfig_optional.patch (706 bytes) - added by ivank 10 years ago.

Download all attachments as: .zip

Change History (3)

comment:1 Changed 10 years ago by Glyph

Owner: changed from Jean-Paul Calderone to ivank

Thanks for the suggestion. More testability is good.

However, _resolvReadInterval is private and undocumented. If you want to go this route, you can set the _reactor attribute instead. Better fixes for this issue would be:

  • pass a FilePath for self.resolv so that the user can override with an in-memory resolv.conf.
  • pass the reactor as an argument to the constructor so it's no longer private, and tests can use it freely.

Also, such a fix will need some unit tests.

I hope you'll update your patch :).

comment:2 Changed 10 years ago by Glyph

(In case it wasn't clear, I meant set the _reactor attribute to a twisted.internet.task.Clock, or something similar that implements the additional interfaces that Resolver relies on.)

Note: See TracTickets for help on using tickets.