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
|
|
| 12 | 12 | import types |
| 13 | 13 | import copy_reg |
| 14 | 14 | import copy |
| | 15 | import inspect |
| 15 | 16 | |
| 16 | 17 | try: |
| 17 | 18 | import cStringIO as StringIO |
| … |
… |
|
| 20 | 21 | |
| 21 | 22 | # Twisted Imports |
| 22 | 23 | from twisted.python import log |
| | 24 | from twisted.python import reflect |
| 23 | 25 | |
| 24 | 26 | oldModules = {} |
| 25 | 27 | |
| … |
… |
|
| 143 | 145 | obj.versionUpgrade() |
| 144 | 146 | return obj |
| 145 | 147 | |
| 146 | | from twisted.python import reflect |
| 147 | | |
| 148 | 148 | def _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): |
| 152 | 164 | l.append(b) |
| 153 | | return l |
| | 165 | # return all except the unwanted classes |
| | 166 | return l[2:] |
| 154 | 167 | |
| 155 | 168 | class Versioned: |
| 156 | 169 | """ |
diff --git a/twisted/test/test_persisted.py b/twisted/test/test_persisted.py
index ff1912a..b7a93a0 100644
|
a
|
b
|
|
| 112 | 112 | styles.doUpgrade() |
| 113 | 113 | self.failUnless(x.y.upgraded) |
| 114 | 114 | |
| | 115 | |
| | 116 | |
| | 117 | class VersionedSubClass(styles.Versioned): |
| | 118 | pass |
| | 119 | |
| | 120 | |
| | 121 | |
| | 122 | class SecondVersionedSubClass(styles.Versioned): |
| | 123 | pass |
| | 124 | |
| | 125 | |
| | 126 | |
| | 127 | class VersionedSubSubClass(VersionedSubClass): |
| | 128 | pass |
| | 129 | |
| | 130 | |
| | 131 | |
| | 132 | class VersionedDiamondSubClass(VersionedSubSubClass, SecondVersionedSubClass): |
| | 133 | pass |
| | 134 | |
| | 135 | |
| | 136 | |
| | 137 | class 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 | |
| 115 | 152 | class MyEphemeral(styles.Ephemeral): |
| 116 | 153 | |
| 117 | 154 | def __init__(self, x): |
diff --git a/twisted/topfiles/5193.bugfix b/twisted/topfiles/5193.bugfix
new file mode 100644
index 0000000..5c69933
|
a
|
b
|
|
| | 1 | twisted.persisted.styles no longer uses the deprecated allYourBase function |