Update of /cvsroot/modeling/ProjectModeling/Modeling/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv27096/Modeling/tests
Modified Files:
test_Relationship.py
Log Message:
* Relationship.py: added __ne__ (for python 2.1 and 2.2), fixed
FlattenedRelationship.__eq__
* Fixed bug #862182: Validation refusing valid relations between objects
(TODO: tests units for this)
Index: test_Relationship.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_Relationship.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** test_Relationship.py 25 Jul 2003 15:39:04 -0000 1.5
--- test_Relationship.py 20 Jan 2004 15:55:13 -0000 1.6
***************
*** 49,52 ****
--- 49,72 ----
"Tests the relationships"
+ def test_00_equality_n_inequality(self):
+ "[Relationship] __eq__ and __ne__"
+ # we make sure that '==' and '!=' operators behaves as expected
+ # There was a bug in FlattenedRelationship.__eq__: it was always returning
+ # 0 whatever the argument was. This was not detected by python v2.1 and
+ # v2.2 both of which were defaulting to identity comparison for '!='
+ # when __ne__ was undefined (despite the fact that __eq__ was defined).
+ # python2.3 operator '!=' takes '__eq__' into account and that revealed
+ # both the bug and the fact that py2.1 and 2.2
+ rel_ab=model.entityNamed('A').relationshipNamed('toB')
+ rel_ac=model.entityNamed('A').relationshipNamed('toCs')
+ import copy
+ rel_abb=copy.copy(rel_ab) # same, different id()
+ self.failUnless(rel_ab==rel_ab, "rel==rel fails")
+ self.failUnless(rel_ab==rel_abb, "rel==copy(rel) fails")
+ self.failUnless(not rel_ab!=rel_ab, "rel!=rel fails")
+ self.failUnless(not rel_ab!=rel_abb, "rel!=copy(rel) fails")
+ self.failUnless(rel_ab!=rel_ac, "not rel1!=rel2 when rel1!=rel2 !!!")
+ self.failUnless(not rel_ab==rel_ac, "rel1==rel2 when rel1!=rel2 !!!")
+
def test_01_flattenedRelationship(self):
"[Relationship] flattened"
|