Author: jmorliaguet
Date: Tue Oct  4 23:07:07 2005
New Revision: 27941

Modified:
   z3lab/cpsskins/branches/jmo-perspectives/relations/__init__.py
   z3lab/cpsskins/branches/jmo-perspectives/storage/relations.py
Log:

- test fix



Modified: z3lab/cpsskins/branches/jmo-perspectives/relations/__init__.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/relations/__init__.py      
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/relations/__init__.py      Tue Oct 
 4 23:07:07 2005
@@ -212,10 +212,7 @@
     '_ is white'
 
     >>> r
-    <Monadic relation: _ is white>
-
-    >>> r()
-    'snow is white'
+    <Monadic relation: 'snow is white'>
 
     >>> relates = r.values()
     >>> relates[0] is first
@@ -239,7 +236,8 @@
             "A monadic relation only has a first element."
 
     def __repr__(self):
-        return '<Monadic relation: %s>' % str(self)
+        predicate = str(self()).replace('_', '%s')
+        return "<Monadic relation: '%s'>" % (predicate % str(self.first))
 
 
 class DyadicRelation(Relation):
@@ -256,10 +254,7 @@
     '_ has format _'
 
     >>> r
-    <Dyadic relation: _ has format _>
-
-    >>> r()
-    'Box has format Vertical Menu'
+    <Dyadic relation: 'Box has format Vertical Menu'>
 
     >>> relates = r.values()
     >>> relates[0] is first
@@ -290,7 +285,10 @@
             "A dyadic relation only has a first and a second element."
 
     def __repr__(self):
-        return '<Dyadic relation: %s>' % str(self)
+        predicate = str(self()).replace('_', '%s')
+        return "<Dyadic relation: '%s'>" % (
+            predicate % (str(self.first), str(self.second))
+            )
 
 
 class TriadicRelation(Relation):
@@ -308,10 +306,7 @@
     '_ converts _ into _'
 
     >>> r
-    <Triadic relation: _ converts _ into _>
-
-    >>> r()
-    'converter converts text into html'
+    <Triadic relation: 'converter converts text into html'>
 
     >>> relates = r.values()
     >>> relates[0] is first
@@ -349,7 +344,10 @@
             "A triadic relation only has a first, second and third element."
 
     def __repr__(self):
-        return '<Triadic relation: %s>' % str(self)
+        predicate = str(self()).replace('_', '%s')
+        return "<Triadic relation: '%s'>" % (
+            predicate % (str(self.first), str(self.second), str(self.third))
+            )
 
 class TestRelate:
     """A relatable object for testing.

Modified: z3lab/cpsskins/branches/jmo-perspectives/storage/relations.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/storage/relations.py       
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/storage/relations.py       Tue Oct 
 4 23:07:07 2005
@@ -17,6 +17,8 @@
 """
 __docformat__ = "reStructuredText"
 
+from pprint import pprint
+
 from BTrees.OOBTree import OOBTree
 
 from zope.app import zapi
@@ -71,8 +73,8 @@
     >>> predicate = Predicate('_ depends on _')
     >>> r = DyadicRelation(predicate, first, second)
 
-    >>> r()
-    'this depends on that'
+    >>> r
+    <Dyadic relation: 'this depends on that'>
 
     >>> list(storage._relates.keys())
     []
@@ -183,19 +185,17 @@
     >>> storage['some_black'] = b_is_black
 
     The relations matching '_ is white' are:
-    >>> res = storage.list(Predicate(is_white))
-    >>> res, [storage[r] for r in res]
-    ([u'some_white'], ['snow is white'])
+    >>> pprint([repr(storage[r]) for r in storage.list(Predicate(is_white))])
+    ["<Monadic relation: 'snow is white'>"]
 
     The relations matching '_ is black' are:
-    >>> res = storage.list(Predicate(is_black))
-    >>> res, [storage[r] for r in res]
-    ([u'some_black'], ['ebony is black'])
+    >>> pprint([repr(storage[r]) for r in storage.list(Predicate(is_black))])
+    ["<Monadic relation: 'ebony is black'>"]
 
     Relations matching the compound ('_ is black', '_is white') are:
     >>> res = storage.list(CompoundPredicate(is_black_or_white))
-    >>> res, [storage[r] for r in res]
-    ([u'some_black', u'some_white'], ['ebony is black', 'snow is white'])
+    >>> pprint([repr(storage[r]) for r in res])
+    ["<Monadic relation: 'ebony is black'>", "<Monadic relation: 'snow is 
white'>"]
 
     Finally, we clear the storage:
     >>> list(storage.keys())
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to