[Zodb-checkins] SVN: ZODB/branches/3.3/src/ZopeUndo/ Merge checkin
made from a wrong project.
Tim Peters
tim.one at comcast.net
Wed Mar 30 15:54:15 EST 2005
Log message for revision 29735:
Merge checkin made from a wrong project.
Believe it or not, ZopeUndo is ZEO code, not Zope code.
r29726 | slinkp | 2005-03-30 02:11:22 -0500 (Wed, 30 Mar 2005) | 3 lines
Changed paths:
M /Zope/trunk/lib/python/ZopeUndo/Prefix.py
M /Zope/trunk/lib/python/ZopeUndo/tests/testPrefix.py
Merged slinkp_1726_zopeundo: avoid showing undo transactions in
the wrong folder.
Changed:
U ZODB/branches/3.3/src/ZopeUndo/Prefix.py
U ZODB/branches/3.3/src/ZopeUndo/tests/testPrefix.py
-=-
Modified: ZODB/branches/3.3/src/ZopeUndo/Prefix.py
===================================================================
--- ZODB/branches/3.3/src/ZopeUndo/Prefix.py 2005-03-30 20:24:53 UTC (rev 29734)
+++ ZODB/branches/3.3/src/ZopeUndo/Prefix.py 2005-03-30 20:54:12 UTC (rev 29735)
@@ -20,20 +20,27 @@
"""
class Prefix:
- """A Prefix() is equal to any string it as a prefix of.
+ """A Prefix() is equal to any path it is a prefix of.
- This class can be compared to a string (or arbitrary sequence).
- The comparison will return True if the prefix value is a prefix of
- the string being compared.
- Two prefixes can not be compared.
+ This class can be compared to a string.
+ The comparison will return True if all path elements of the
+ Prefix are found at the beginning of the string being compared.
+
+ Two Prefixes can not be compared.
"""
__no_side_effects__ = 1
def __init__(self, path):
- self.value = len(path), path
+ path_list = path.split('/')
+ self.length = len(path_list)
+ self.path = path_list
def __cmp__(self, o):
- l, v = self.value
- return cmp(o[:l], v)
+ other_path = o.split('/')
+ return cmp(other_path[:self.length], self.path)
+
+ def __repr__(self):
+ # makes failing tests easier to read
+ return "Prefix('%s')" % '/'.join(self.path)
Modified: ZODB/branches/3.3/src/ZopeUndo/tests/testPrefix.py
===================================================================
--- ZODB/branches/3.3/src/ZopeUndo/tests/testPrefix.py 2005-03-30 20:24:53 UTC (rev 29734)
+++ ZODB/branches/3.3/src/ZopeUndo/tests/testPrefix.py 2005-03-30 20:54:12 UTC (rev 29735)
@@ -18,19 +18,15 @@
class PrefixTest(unittest.TestCase):
def test(self):
- p1 = (Prefix("/a/b"),
- ("/a/b", "/a/b/c", "/a/b/c/d"),
- ("", "/a/c"))
+ p1 = Prefix("/a/b")
+ for equal in ("/a/b", "/a/b/c", "/a/b/c/d"):
+ self.assertEqual(p1, equal)
+ for notEqual in ("", "/a/c", "/a/bbb", "///"):
+ self.assertNotEqual(p1, notEqual)
- p2 = (Prefix(""),
- ("", "/def", "/a/b", "/a/b/c", "/a/b/c/d"),
- ())
+ p2 = Prefix("")
+ for equal in ("", "/", "/def", "/a/b", "/a/b/c", "/a/b/c/d"):
+ self.assertEqual(p2, equal)
- for prefix, equal, notequal in p1, p2:
- for s in equal:
- self.assertEqual(prefix, s)
- for s in notequal:
- self.assertNotEqual(prefix, s)
-
def test_suite():
return unittest.makeSuite(PrefixTest)
More information about the Zodb-checkins
mailing list