[test] Avoid assertCountEqual in unittest_syncschema.py
authorDenis Laxalde <denis.laxalde@logilab.fr>
Tue, 21 Jun 2016 18:11:40 +0200
changeset 11341 bd3cd3691ade
parent 11340 e68991426d7d
child 11342 62a7100d774b
[test] Avoid assertCountEqual in unittest_syncschema.py It's not clear why this happens, but it seems that assertCountEqual does strange things with unittest2 on Python 2 for equality comparison (trying to sort constraint objects, even though BaseConstraint raise NotImplemented in __lt__ from Yams 0.43). So just avoid using it to get this test passing.
cubicweb/hooks/test/unittest_syncschema.py
--- a/cubicweb/hooks/test/unittest_syncschema.py	Wed Jun 22 11:01:16 2016 +0200
+++ b/cubicweb/hooks/test/unittest_syncschema.py	Tue Jun 21 18:11:40 2016 +0200
@@ -398,7 +398,9 @@
                         'EDEF constrained_by X WHERE CT name %(ct)s, EDEF eid %(x)s',
                         {'ct': cstr3.__class__.__name__, 'v': cstr3.serialize(), 'x': rdef.eid})
             cnx.commit()
-            self.assertCountEqual(rdef.constraints, [cstr, cstr3])
+            # Do not use assertCountEqual as it does "strange" equality
+            # comparison on Python 2.
+            self.assertEqual(set(rdef.constraints), set([cstr, cstr3]))
 
 
 if __name__ == '__main__':