Ticket #5451: patch_demo.patch

File patch_demo.patch, 2.6 KB (added by moijes12, 5 years ago)

This is a demo patch. I'm having some trouble deprecating PropertyAccessorType and Accessor.

  • 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.assertEqual(warnings[0]['message'], "twisted.python.reflect.Settable was deprecated in Twisted 12.1.0")
     792        self.assertEqual(len(warnings), 1)
     793
     794    def test_accessorType(self):
     795        """
     796        Test deprecation of L{reflect.AccessorType}
     797        """
     798        accessor = reflect.AccessorType('',(),{})
     799        warnings = self.flushWarnings([self.test_accessorType])
     800        self.assertEqual(warnings[0]['message'], "twisted.python.reflect.AccessorType was deprecated in Twisted 12.1.0")
     801        self.assertEqual(len(warnings), 1)
     802
     803    def test_summer(self):
     804        """
     805        Test deprecation of L{reflect.Summer}.
     806        """
     807        summer = reflect.Summer()
     808        warnings = self.flushWarnings([self.test_summer])
     809        self.assertEqual(warnings[0]['message'], "twisted.python.reflect.Summer was deprecated in Twisted 12.1.0")
     810        self.assertEqual(len(warnings), 1)
  • twisted/python/reflect.py

     
    3535from twisted.python.versions import Version
    3636
    3737
    38 
     38@deprecated(Version("Twisted", 12, 1, 0))
    3939class Settable:
    4040    """
    4141    A mixin class for syntactic sugar.  Lets you assign attributes by
     
    5252            setattr(self,key,val)
    5353        return self
    5454
    55 
     55@deprecated(Version("Twisted", 12, 1, 0))
    5656class AccessorType(type):
    5757    """Metaclass that generates properties automatically.
    5858
     
    139139    #  -- itamar
    140140
    141141    __metaclass__ = AccessorType
    142 
     142   
    143143    def reallySet(self, k, v):
    144144        self.__dict__[k] = v
    145145
    146146    def reallyDel(self, k):
    147147        del self.__dict__[k]
    148148
    149 
    150149class Accessor:
    151150    """
    152151    Extending this class will give you explicit accessor methods; a
     
    200199# just in case
    201200OriginalAccessor = Accessor
    202201
    203 
     202@deprecated(Version("Twisted", 12, 1, 0))
    204203class Summer(Accessor):
    205204    """
    206205    Extend from this class to get the capability to maintain 'related