Ticket #5193: bug5193-1.patch

File bug5193-1.patch, 2.9 KB (added by dustin, 5 years ago)

5193-1.patch

  • twisted/persisted/styles.py

    commit 2e23f0d59ca934e8e13046f6ee91aa1a54261c81
    Author: Dustin J. Mitchell <dustin@zmanda.com>
    Date:   Sat Jul 9 18:38:30 2011 -0500
    
        tests
    
    diff --git a/twisted/persisted/styles.py b/twisted/persisted/styles.py
    index bf89467..fb85cd9 100644
    a b Different styles of persisted objects. 
    1212import types
    1313import copy_reg
    1414import copy
     15import inspect
    1516
    1617try:
    1718    import cStringIO as StringIO
    except ImportError: 
    2021
    2122# Twisted Imports
    2223from twisted.python import log
     24from twisted.python import reflect
    2325
    2426oldModules = {}
    2527
    def requireUpgrade(obj): 
    143145        obj.versionUpgrade()
    144146        return obj
    145147
    146 from twisted.python import reflect
    147 
    148148def _aybabtu(c):
    149     l = []
    150     for b in reflect.allYourBase(c, Versioned):
    151         if b not in l and b is not Versioned:
     149    """
     150    Get all of the parent classes of C{c}, not including C{c} itself, which are
     151    strict subclasses of L{Versioned}.
     152
     153    The name comes from "all your base are belong to us", from the deprecated
     154    L{twisted.python.reflect.allYourBase} function.
     155
     156    @param c: a class
     157    @returns: list of classes
     158    """
     159    # begin with two classes that should *not* be included in the
     160    # final result
     161    l = [ c, Versioned ]
     162    for b in inspect.getmro(c):
     163        if b not in l and issubclass(b, Versioned):
    152164            l.append(b)
    153     return l
     165    # return all except the unwanted classes
     166    return l[2:]
    154167
    155168class Versioned:
    156169    """
  • twisted/test/test_persisted.py

    diff --git a/twisted/test/test_persisted.py b/twisted/test/test_persisted.py
    index ff1912a..b7a93a0 100644
    a b class VersionTestCase(unittest.TestCase): 
    112112        styles.doUpgrade()
    113113        self.failUnless(x.y.upgraded)
    114114
     115
     116
     117class VersionedSubClass(styles.Versioned):
     118    pass
     119
     120
     121
     122class SecondVersionedSubClass(styles.Versioned):
     123    pass
     124
     125
     126
     127class VersionedSubSubClass(VersionedSubClass):
     128    pass
     129
     130
     131
     132class VersionedDiamondSubClass(VersionedSubSubClass, SecondVersionedSubClass):
     133    pass
     134
     135
     136
     137class AybabtuTests(unittest.TestCase):
     138
     139
     140    def testAybabtu(self):
     141        """
     142        Test styles._aybabtu, including edge cases.
     143        """
     144        self.assertEqual(styles._aybabtu(styles.Versioned), [])
     145        self.assertEqual(styles._aybabtu(VersionedSubClass), [])
     146        self.assertEqual(styles._aybabtu(VersionedSubSubClass),
     147            [VersionedSubClass])
     148        self.assertEqual(styles._aybabtu(VersionedDiamondSubClass),
     149            [VersionedSubSubClass, VersionedSubClass, SecondVersionedSubClass])
     150
     151
    115152class MyEphemeral(styles.Ephemeral):
    116153
    117154    def __init__(self, x):
  • new file twisted/topfiles/5193.bugfix

    diff --git a/twisted/topfiles/5193.bugfix b/twisted/topfiles/5193.bugfix
    new file mode 100644
    index 0000000..5c69933
    - +  
     1twisted.persisted.styles no longer uses the deprecated allYourBase function