[Modeling-cvs] SF.net SVN: modeling: [972] trunk/ProjectModeling
Status: Abandoned
Brought to you by:
sbigaret
From: <sbi...@us...> - 2006-02-26 01:27:21
|
Revision: 972 Author: sbigaret Date: 2006-02-25 17:27:05 -0800 (Sat, 25 Feb 2006) ViewCVS: http://svn.sourceforge.net/modeling/?rev=972&view=rev Log Message: ----------- Fixed bug #918115: tests were failing under py2.1 w/ ZODB was installed, plus: relationships equality was not behaving as expected under py2.1 and 2.2, because these versions of python use __cmp__ rather than __eq__ Modified Paths: -------------- trunk/ProjectModeling/CHANGES trunk/ProjectModeling/Modeling/ChangeLog trunk/ProjectModeling/Modeling/Relationship.py trunk/ProjectModeling/Modeling/tests/test_Relationship.py Modified: trunk/ProjectModeling/CHANGES =================================================================== --- trunk/ProjectModeling/CHANGES 2006-02-25 23:49:51 UTC (rev 971) +++ trunk/ProjectModeling/CHANGES 2006-02-26 01:27:05 UTC (rev 972) @@ -9,6 +9,10 @@ * Now distributed under a 3-clause BSD-style license, see LICENSE for details + * Fixed bug #918115: tests were failing under py2.1 w/ ZODB was installed, + plus: relationships equality was not behaving as expected under py2.1 and + 2.2, because these versions of python use __cmp__ rather than __eq__ + * Fixed: Attribute.convertStringToAttributeType() failed when python db-adapters, such as mysqldb, already return values under the a date type Modified: trunk/ProjectModeling/Modeling/ChangeLog =================================================================== --- trunk/ProjectModeling/Modeling/ChangeLog 2006-02-25 23:49:51 UTC (rev 971) +++ trunk/ProjectModeling/Modeling/ChangeLog 2006-02-26 01:27:05 UTC (rev 972) @@ -1,3 +1,10 @@ +2006-02-26 Sebastien Bigaret <Seb...@en...> + + * Relationship.py (Relationship.__cmp__): added for py2.1 and 2.2, + or equality is not correcty handled (bug #918115) + * utils.py (cache_simple_methods): disabled under py2.1 when ZODB + is installed (bug #918115) + 2006-02-25 Sebastien Bigaret <Seb...@en...> * Attribute.py (date_types): added python date and datetime types Modified: trunk/ProjectModeling/Modeling/Relationship.py =================================================================== --- trunk/ProjectModeling/Modeling/Relationship.py 2006-02-25 23:49:51 UTC (rev 971) +++ trunk/ProjectModeling/Modeling/Relationship.py 2006-02-26 01:27:05 UTC (rev 972) @@ -227,6 +227,12 @@ def __ne__(self, aRelationship): # See test_Relationship.test_00_equality_n_inequality() for details return not self.__eq__(aRelationship) + + import sys + if sys.version_info < (2,3): + def __cmp__(self, r): + return not self.__eq__(r) + # XMLCapabilityInterface def initWithXMLDOMNode(self, aNode, encoding='iso-8859-1'): Modified: trunk/ProjectModeling/Modeling/tests/test_Relationship.py =================================================================== --- trunk/ProjectModeling/Modeling/tests/test_Relationship.py 2006-02-25 23:49:51 UTC (rev 971) +++ trunk/ProjectModeling/Modeling/tests/test_Relationship.py 2006-02-26 01:27:05 UTC (rev 972) @@ -16,13 +16,13 @@ from __future__ import nested_scopes -import unittest +import unittest, sys if __name__ == "__main__": - import utils, sys + import utils utils.disable_model_cache() utils.fixpath() -from Modeling import ModelSet +from Modeling import ModelSet, Relationship import StoreEmployees # load the model @@ -46,11 +46,22 @@ # 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 + # both the bug and the fact that py2.1 and 2.2 rely on __cmp__ instead of + # __eq__ 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() + if sys.version_info < (2,3): + # simulates copy, because it fails if ZODB is installed (because of + # extension class) + rel_abb=Relationship.SimpleRelationship('toB') + for k in rel_ab.__dict__.keys(): + setattr(rel_abb, k, getattr(rel_ab, k)) + else: + rel_abb = copy.copy(rel_ab) + + self.assertNotEqual(id(rel_ab), id(rel_abb)) 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") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |