=== modified file 'twisted/lore/test/test_lore.py'
|
|
|
|
| 1197 | 1197 | """ |
| 1198 | 1198 | processor = lore.getProcessor("lore", "html", options) |
| 1199 | 1199 | self.assertNotIdentical(processor, None) |
| 1200 | | |
| 1201 | | |
| 1202 | | |
| 1203 | | class DeprecationTests(unittest.TestCase): |
| 1204 | | """ |
| 1205 | | Tests for deprecated APIs in L{twisted.lore.tree}. |
| 1206 | | """ |
| 1207 | | def test_comparePosition(self): |
| 1208 | | """ |
| 1209 | | L{tree.comparePosition} is deprecated. |
| 1210 | | """ |
| 1211 | | from twisted.web.microdom import parseString |
| 1212 | | element = parseString('<foo/>').documentElement |
| 1213 | | self.assertEqual( |
| 1214 | | self.callDeprecated( |
| 1215 | | Version('Twisted', 9, 0, 0), |
| 1216 | | tree.comparePosition, element, element), |
| 1217 | | 0) |
| 1218 | | |
| 1219 | | |
| 1220 | | def test_compareMarkPos(self): |
| 1221 | | """ |
| 1222 | | L{tree.compareMarkPos} is deprecated. |
| 1223 | | """ |
| 1224 | | self.assertEqual( |
| 1225 | | self.callDeprecated( |
| 1226 | | Version('Twisted', 9, 0, 0), |
| 1227 | | tree.compareMarkPos, [0, 1], [1, 2]), |
| 1228 | | -1) |
=== modified file 'twisted/lore/tree.py'
|
|
|
|
| 12 | 12 | |
| 13 | 13 | from twisted.python import htmlizer, text |
| 14 | 14 | from twisted.python.filepath import FilePath |
| 15 | | from twisted.python.deprecate import deprecated |
| 16 | 15 | from twisted.python.versions import Version |
| 17 | 16 | from twisted.web import domhelpers |
| 18 | 17 | import process, latex, indexer, numberer, htmlbook |
| … |
… |
|
| 471 | 470 | |
| 472 | 471 | |
| 473 | 472 | |
| 474 | | def compareMarkPos(a, b): |
| 475 | | """ |
| 476 | | Perform in every way identically to L{cmp} for valid inputs. |
| 477 | | """ |
| 478 | | linecmp = cmp(a[0], b[0]) |
| 479 | | if linecmp: |
| 480 | | return linecmp |
| 481 | | return cmp(a[1], b[1]) |
| 482 | | compareMarkPos = deprecated(Version('Twisted', 9, 0, 0))(compareMarkPos) |
| 483 | | |
| 484 | | |
| 485 | | |
| 486 | | def comparePosition(firstElement, secondElement): |
| 487 | | """ |
| 488 | | Compare the two elements given by their position in the document or |
| 489 | | documents they were parsed from. |
| 490 | | |
| 491 | | @type firstElement: C{dom.Element} |
| 492 | | @type secondElement: C{dom.Element} |
| 493 | | |
| 494 | | @return: C{-1}, C{0}, or C{1}, with the same meanings as the return value |
| 495 | | of L{cmp}. |
| 496 | | """ |
| 497 | | return cmp(firstElement._markpos, secondElement._markpos) |
| 498 | | comparePosition = deprecated(Version('Twisted', 9, 0, 0))(comparePosition) |
| 499 | | |
| 500 | | |
| 501 | | |
| 502 | 473 | def findNodeJustBefore(target, nodes): |
| 503 | 474 | """ |
| 504 | 475 | Find the last Element which is a sibling of C{target} and is in C{nodes}. |