Opened 8 years ago

Closed 8 years ago

#5486 enhancement closed wontfix (wontfix)

Perhaps there should be an API for unregistering adapters

Reported by: Drew Smathers Owned by: Drew Smathers
Priority: normal Milestone:
Component: core Keywords:
Cc: Branch:


For unit tests it can be useful to register an adapter to provide some fake object for an API, but leaking this state is not desirable. There should perhaps be a set of APIs to allow cooperative registration of adapters for use in unit testing.

Change History (1)

comment:1 Changed 8 years ago by Jean-Paul Calderone

Resolution: wontfix
Status: newclosed

This isn't actually necessary. Leaking registrations doesn't actually cause any problems. It's possible _addHook and _removeHook should be public (or an equivalent but more suitable public API added to supersede them) so that an alternate registry entirely could be used by unit tests, avoiding shared global state, however considering Twisted itself (nor any of the Twisted-based projects I can recall working on) have suffered from this, I feel it probably isn't worthwhile.

Unregistering specific adapters is probably not the way to go, in any case. What you really want in unit tests to avoid polluting global state is a way to say "now forget every thing I did to the adapter registry since the test started", and that sounds more like a swap-to-alternate-pristine-registry-then-swap-back to me.

Note: See TracTickets for help on using tickets.