Ticket #5451: patch_5451.patch

File patch_5451.patch, 5.1 KB (added by moijes12, 4 years ago)

Settable, AccessorType, PropertyAccessor, Accessor, OriginalAccessor and Summer are deprecated ( version used is 12.1.0) . Unit Tests are created in test_reflect.py and news files entry is made in twisted/topfiles

  • twisted/python/reflect.py

     
    3333from twisted.python.deprecate import deprecated
    3434from twisted.python.deprecate import _fullyQualifiedName as fullyQualifiedName
    3535from twisted.python.versions import Version
     36from twisted.python import deprecate
    3637
    3738
    3839
     
    4445    where you don't want to name a variable, but you do want to set
    4546    some attributes; for example, C{X()(y=z,a=b)}.
    4647    """
     48
     49    deprecate.deprecatedModuleAttribute(Version("Twisted", 12, 1, 0), "", "twisted.python.reflect", "Settable")
     50
    4751    def __init__(self, **kw):
    4852        self(**kw)
    4953
     
    7579
    7680    """
    7781
     82    deprecate.deprecatedModuleAttribute(Version("Twisted", 12, 1, 0), "", "twisted.python.reflect", "AccessorType")
     83
    7884    def __init__(self, name, bases, d):
    7985        type.__init__(self, name, bases, d)
    8086        accessors = {}
     
    138144    # caused by it.
    139145    #  -- itamar
    140146
     147    deprecate.deprecatedModuleAttribute(Version("Twisted", 12, 1, 0), "", "twisted.python.reflect", "PropertyAccessor")
    141148    __metaclass__ = AccessorType
    142149
    143150    def reallySet(self, k, v):
     
    159166    This implementation is for Python 2.1.
    160167    """
    161168
     169    deprecate.deprecatedModuleAttribute(Version("Twisted", 12, 1, 0), "", "twisted.python.reflect", "Accessor")
     170
    162171    def __setattr__(self, k,v):
    163172        kstring='set_%s'%k
    164173        if hasattr(self.__class__,kstring):
     
    199208
    200209# just in case
    201210OriginalAccessor = Accessor
    202 
     211deprecate.deprecatedModuleAttribute(Version("Twisted", 12, 1, 0), "", "twisted.python.reflect", "OriginalAccessor")
    203212
    204213class Summer(Accessor):
    205214    """
     
    214223    incremented, similiarly for the debit versions.
    215224    """
    216225
     226    deprecate.deprecatedModuleAttribute(Version("Twisted", 12, 1, 0), "", "twisted.python.reflect", "Summer")
     227
    217228    def reallySet(self, k,v):
    218229        "This method does the work."
    219230        for sum in self.sums:
  • twisted/topfiles/5451.removal

     
     1twisted.python.reflect's Settable, AccessorType, PropertyAccessor, Accessor, OriginalAccessor and Summer are now deprecated.
     2 No newline at end of file
  • twisted/test/test_reflect.py

     
    781781        self.callDeprecated(
    782782            (Version("Twisted", 11, 0, 0), "inspect.getmro"),
    783783            reflect.accumulateBases, DeprecationTestCase, l, None)
     784
     785    def test_settable(self):
     786        """
     787        Test deprecation of L{reflect.Settable}
     788        """
     789        settable = reflect.Settable()
     790        warnings = self.flushWarnings([self.test_settable])
     791        self.assertSubstring("twisted.python.reflect.Settable was deprecated in Twisted 12.1.0", warnings[0]['message'])
     792        self.assertEqual(len(warnings),1)
     793
     794    def test_accessorType(self):
     795        """
     796        Test deprecation of L{reflect.AccessorType}
     797        """
     798        accessorType = reflect.AccessorType('', (), {})
     799        warnings = self.flushWarnings([self.test_accessorType])
     800        self.assertSubstring("twisted.python.reflect.AccessorType was deprecated in Twisted 12.1.0", warnings[0]['message'])
     801        self.assertEqual(len(warnings),1)
     802
     803    def test_propertyAccessor(self):
     804        """
     805        Test deprecation of L{reflect.PropertyAccessor}
     806        """
     807        accessorType = reflect.PropertyAccessor()
     808        warnings = self.flushWarnings([self.test_propertyAccessor])
     809        self.assertSubstring("twisted.python.reflect.PropertyAccessor was deprecated in Twisted 12.1.0", warnings[0]['message'])
     810        self.assertEqual(len(warnings),1)
     811
     812    def test_accessor(self):
     813        """
     814        Test deprecation of L{reflect.Accessor}
     815        """
     816        accessorType = reflect.Accessor()
     817        warnings = self.flushWarnings([self.test_accessor])
     818        self.assertSubstring("twisted.python.reflect.Accessor was deprecated in Twisted 12.1.0", warnings[0]['message'])
     819        self.assertEqual(len(warnings),1)
     820
     821    def test_originalAccessor(self):
     822        """
     823        Test deprecation of L{reflect.OriginalAccessor}
     824        """
     825        from twisted.python.reflect import OriginalAccessor
     826        warnings = self.flushWarnings([self.test_originalAccessor])
     827        self.assertSubstring("twisted.python.reflect.OriginalAccessor was deprecated in Twisted 12.1.0", warnings[0]['message'])
     828        self.assertEqual(len(warnings),1)
     829
     830    def test_summer(self):
     831        """
     832        Test deprecation of L{reflect.Summer}
     833        """
     834        accessorType = reflect.Summer()
     835        warnings = self.flushWarnings([self.test_summer])
     836        self.assertSubstring("twisted.python.reflect.Summer was deprecated in Twisted 12.1.0", warnings[0]['message'])
     837        self.assertEqual(len(warnings),1)
     838 No newline at end of file