[Twisted-Python] Deprecating classes and writing tests

Glyph glyph at twistedmatrix.com
Mon Jun 13 15:46:29 MDT 2016


> On Jun 13, 2016, at 4:26 AM, Adi Roiban <adi at roiban.ro> wrote:
> 
> Hi,
> 
> What is the best practice for deprecating a class in Twisted and writing tests for it ... and updating existing tests.

We appear to have 'assertDeprecated' type methods scattered around the codebase.  These should be refactored into a single location.

> I think that the part in which the deprecation code is written, is well understood and documented here
> 
> http://twistedmatrix.com/documents/current/core/development/policy/compatibility-policy.html#classes <http://twistedmatrix.com/documents/current/core/development/policy/compatibility-policy.html#classes>
> 
> What is missing, is the part talking about how to test these changes and how to update existing tests.

The thing that ends up being deprecated with the recommended technique here is the import of the class itself. So I think what's missing is the explanation that the import needs to be moved to test scope, not module scope within the tests.  The tests should also be separated out and dated so it's clear what to delete when the deprecation period expires, and removals are easy.

Does that answer your question sufficiently?

-glyph

-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20160613/d4a59bd5/attachment-0002.html>


More information about the Twisted-Python mailing list