Ticket #5852: 5852.2.patch

File 5852.2.patch, 2.5 KB (added by moijes12, 3 years ago)
  • twisted/mail/smtp.py

     
    88
    99import time, re, base64, types, socket, os, random, rfc822
    1010import binascii
     11import warnings
    1112from email.base64MIME import encode as encode_base64
    1213
    1314from zope.interface import implements, Interface
     
    12391240    # ClientContextFactory to use for STARTTLS
    12401241    context = None
    12411242
     1243
     1244    def __setattr__(self, name, val):
     1245        if name == 'tlsMode':
     1246            warnings.warn("tlsMode attribute of twisted.mail.smtp.ESMTPClient is deprecated since Twisted 12.2", category=DeprecationWarning, stacklevel=2)
     1247        self.__dict__[name] = val
     1248
     1249     
    12421250    def __init__(self, secret, contextFactory=None, *args, **kw):
    12431251        SMTPClient.__init__(self, *args, **kw)
    12441252        self.authenticators = []
  • twisted/mail/test/test_smtp.py

     
    609609    def test_loginAuth(self):
    610610        """
    611611        L{ESMTPClient} can authenticate using the I{LOGIN} SASL mechanism.
     612       
    612613
    613614        @see: U{http://sepp.oetiker.ch/sasl-2.1.19-ds/draft-murchison-sasl-login-00.txt}
    614615        """
     
    15181519        client.sentMail(199, "Test response", 1, addresses, client.log)
    15191520
    15201521        return onDone
     1522
     1523
     1524
     1525class DeprecationTests(unittest.TestCase):
     1526    """
     1527    Test for deprecations.
     1528    """
     1529
     1530
     1531    def test_esmtpClientTlsModeDeprecation(self):
     1532        """
     1533        Test deprecation of ESMTPClient.tlsMode.
     1534        """
     1535        import warnings
     1536        with warnings.catch_warnings(record=True) as w:
     1537            warnings.simplefilter("default")
     1538            from twisted.mail.smtp import ESMTPClient
     1539            client = ESMTPClient('', '', '')
     1540            self.assertEqual(len(w), 1)
     1541            self.assertIdentical(w[-1].category, DeprecationWarning)
     1542            self.assertEqual(str(w[-1].message), "tlsMode attribute of twisted.mail.smtp.ESMTPClient is deprecated since Twisted 12.2")
  • twisted/mail/topfiles/5852.removal

     
     1tlsMode attribute of twisted.mail.smtp.ESMTPClient is deprecated since Twisted 12.2.