Ticket #6547: my-twisted-patch1.patch

File my-twisted-patch1.patch, 2.8 KB (added by mulhern, 9 years ago)

New patch deprecates instead of removes.

  • twisted/mail/test/test_pb.py

     
     1# Copyright (c) Twisted Matrix Laboratories.
     2# See LICENSE for details.
     3
     4from twisted.trial import unittest
     5
     6from twisted import mail
     7import twisted.mail.pb
     8
     9class MaildirBrokerTests(unittest.TestCase):
     10    """
     11    Tests that L{twistd.mail.pb.MaildirBroker} is deprecated and the reason
     12    for the deprecation which is that invoking either of the two methods
     13    defined in the class will fail with an attribute error.
     14    """
     15
     16    def test_deprecation(self):
     17        """
     18        Tests both deprecation warning and AttributeError for both methods.
     19        """
     20        mb = mail.pb.MaildirBroker()
     21        warningsShown = self.flushWarnings([self.test_deprecation])
     22        self.assertEqual(len(warningsShown), 1)
     23        self.assertIdentical(warningsShown[0]['category'], DeprecationWarning)
     24        self.assertEqual(
     25            warningsShown[0]['message'],
     26            "twisted.mail.pb.MaildirBroker was deprecated in Twisted 13.0.0: There is no suggested replacement for this class.")
     27        self.assertRaises(AttributeError,
     28                          mail.pb.MaildirBroker.proto_getCollection,
     29                          mb,
     30                          None,
     31                          None,
     32                          None,
     33                          None)
     34        self.assertRaises(AttributeError,
     35                          mail.pb.MaildirBroker.getCollection,
     36                          mb,
     37                          None,
     38                          None,
     39                          None)
  • twisted/mail/topfiles/6547.removal

     
     1twisted.mail.MaildirBroker deprecated because both its methods are obsolete and fail with an AttributeError if invoked.
  • twisted/mail/pb.py

     
    22# See LICENSE for details.
    33
    44
     5from twisted.python.deprecate import deprecatedModuleAttribute
     6from twisted.python.versions import Version
    57from twisted.spread import pb
    68from twisted.spread import banana
    79
     
    9193
    9294class MaildirBroker(pb.Broker):
    9395
     96    deprecatedModuleAttribute(
     97        Version("Twisted", 13, 0, 0),
     98        "There is no suggested replacement for this class.",
     99        "twisted.mail.pb",
     100        "MaildirBroker")
     101
    94102    def proto_getCollection(self, requestID, name, domain, password):
    95103        collection = self._getCollection()
    96104        if collection is None: