Ticket #6395: deprecated_msn_added_corrections_2.2.patch

File deprecated_msn_added_corrections_2.2.patch, 2.6 KB (added by Indradhanush Gupta, 6 years ago)

Made changes according to review points. But trial twisted generates 2 errors.

  • twisted/words/protocols/msn.py

     
    7171@author: Sam Jordan
    7272"""
    7373
     74import warnings
     75warnings.warn(
     76    "As of Twisted 13.0.0, twisted.words.protocols.msn is deprecated.  "
     77    "Reason : MSN is being shut down",
     78    DeprecationWarning,
     79    stacklevel=2)
     80
     81
    7482import types, operator, os
    7583from random import randint
    7684from urllib import quote, unquote
  • twisted/words/protocols/__init__.py

     
     1# Copyright (c) Twisted Matrix Laboratories.
     2# See LICENSE for details.
     3
    14"Chat protocols"
     5
     6
  • twisted/words/topfiles/6395.removal

     
     1twisted.words.protocols.msn is now deprecated.
  • twisted/words/test/test_msn.py

     
    2323    # Otherwise importing it should work, so do it.
    2424    from twisted.words.protocols import msn
    2525
    26 
     26from twisted.trial import unittest
    2727from twisted.python.hashlib import md5
    2828from twisted.protocols import loopback
    2929from twisted.internet.defer import Deferred
     
    520520        testClass.skip = (
    521521            "MSN requires an HTTP client but none is available, "
    522522            "skipping tests.")
     523
     524
     525class Deprecations(unittest.TestCase):
     526    """
     527    Tests to ensure deprecation of L{twisted.words.protocols.msn}
     528    """
     529
     530    def ensureDeprecated(self, message):
     531        """
     532        Ensures that the correct deprecation warning was issued.
     533        """
     534        warnings = self.flushWarnings(self.test_msnDeprecated)
     535        self.assertIdentical(warnings[0]['category'], DeprecationWarning)
     536        self.assertEqual(warnings[0]['message'], message)
     537        self.assertEqual(len(warnings), 1)
     538
     539
     540    def test_msnDeprecated(self):
     541        """
     542        When importing twisted.words.protocols.msn L{DeprecationWarning} is reported.
     543        """
     544        from twisted.words.protocols import msn
     545        self.ensureDeprecated("twisted.words.protocols.msn is deprecated "
     546                              "since Twisted 13.0.0")