[test] use assertCountEqual instead of assertItemsEqual stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 01 Aug 2013 13:58:48 +0200
branchstable
changeset 9273 f3795da61959
parent 9272 68744f5154c4
child 9274 b39ac464e3ac
[test] use assertCountEqual instead of assertItemsEqual
server/test/unittest_migractions.py
test/unittest_entity.py
web/test/unittest_uicfg.py
web/test/unittest_views_basecontrollers.py
--- a/server/test/unittest_migractions.py	Thu Oct 10 12:30:02 2013 +0200
+++ b/server/test/unittest_migractions.py	Thu Aug 01 13:58:48 2013 +0200
@@ -434,12 +434,12 @@
         self.mh.commit()
         # unique_together test
         self.assertEqual(len(self.schema.eschema('Personne')._unique_together), 1)
-        self.assertItemsEqual(self.schema.eschema('Personne')._unique_together[0],
+        self.assertCountEqual(self.schema.eschema('Personne')._unique_together[0],
                                            ('nom', 'prenom', 'datenaiss'))
         rset = cursor.execute('Any C WHERE C is CWUniqueTogetherConstraint, C constraint_of ET, ET name "Personne"')
         self.assertEqual(len(rset), 1)
         relations = [r.name for r in rset.get_entity(0, 0).relations]
-        self.assertItemsEqual(relations, ('nom', 'prenom', 'datenaiss'))
+        self.assertCountEqual(relations, ('nom', 'prenom', 'datenaiss'))
 
     def _erqlexpr_rset(self, action, ertype):
         rql = 'RQLExpression X WHERE ET is CWEType, ET %s_permission X, ET name %%(name)s' % action
--- a/test/unittest_entity.py	Thu Oct 10 12:30:02 2013 +0200
+++ b/test/unittest_entity.py	Thu Aug 01 13:58:48 2013 +0200
@@ -150,24 +150,24 @@
         p1 = req.create_entity('Personne', nom=u'di')
         p2 = req.create_entity('Personne', nom=u'mascio')
         t = req.create_entity('Tag', name=u't0', tags=[])
-        self.assertItemsEqual(t.tags, [])
+        self.assertCountEqual(t.tags, [])
         t = req.create_entity('Tag', name=u't1', tags=p1)
-        self.assertItemsEqual(t.tags, [p1])
+        self.assertCountEqual(t.tags, [p1])
         t = req.create_entity('Tag', name=u't2', tags=p1.eid)
-        self.assertItemsEqual(t.tags, [p1])
+        self.assertCountEqual(t.tags, [p1])
         t = req.create_entity('Tag', name=u't3', tags=[p1, p2.eid])
-        self.assertItemsEqual(t.tags, [p1, p2])
+        self.assertCountEqual(t.tags, [p1, p2])
 
     def test_cw_instantiate_reverse_relation(self):
         req = self.request()
         t1 = req.create_entity('Tag', name=u't1')
         t2 = req.create_entity('Tag', name=u't2')
         p = req.create_entity('Personne', nom=u'di mascio', reverse_tags=t1)
-        self.assertItemsEqual(p.reverse_tags, [t1])
+        self.assertCountEqual(p.reverse_tags, [t1])
         p = req.create_entity('Personne', nom=u'di mascio', reverse_tags=t1.eid)
-        self.assertItemsEqual(p.reverse_tags, [t1])
+        self.assertCountEqual(p.reverse_tags, [t1])
         p = req.create_entity('Personne', nom=u'di mascio', reverse_tags=[t1, t2.eid])
-        self.assertItemsEqual(p.reverse_tags, [t1, t2])
+        self.assertCountEqual(p.reverse_tags, [t1, t2])
 
     def test_fetch_rql(self):
         user = self.user()
--- a/web/test/unittest_uicfg.py	Thu Oct 10 12:30:02 2013 +0200
+++ b/web/test/unittest_uicfg.py	Thu Aug 01 13:58:48 2013 +0200
@@ -85,15 +85,15 @@
     def test_uihelper_hide_fields(self):
         # original conf : in_group is edited in 'attributes' section everywhere
         section_conf = uicfg.autoform_section.get('CWUser', 'in_group', '*', 'subject')
-        self.assertItemsEqual(section_conf, ['main_attributes', 'muledit_attributes'])
+        self.assertCountEqual(section_conf, ['main_attributes', 'muledit_attributes'])
         # hide field in main form
         uihelper.hide_fields('CWUser', ('login', 'in_group'))
         section_conf = uicfg.autoform_section.get('CWUser', 'in_group', '*', 'subject')
-        self.assertItemsEqual(section_conf, ['main_hidden', 'muledit_attributes'])
+        self.assertCountEqual(section_conf, ['main_hidden', 'muledit_attributes'])
         # hide field in muledit form
         uihelper.hide_fields('CWUser', ('login', 'in_group'), formtype='muledit')
         section_conf = uicfg.autoform_section.get('CWUser', 'in_group', '*', 'subject')
-        self.assertItemsEqual(section_conf, ['main_hidden', 'muledit_hidden'])
+        self.assertCountEqual(section_conf, ['main_hidden', 'muledit_hidden'])
 
     @tag('uihelper', 'hidden', 'formconfig')
     def test_uihelper_formconfig(self):
@@ -103,7 +103,7 @@
             hidden = ('in_group',)
             fields_order = ('login', 'firstname')
         section_conf = uicfg.autoform_section.get('CWUser', 'in_group', '*', 'subject')
-        self.assertItemsEqual(section_conf, ['main_hidden', 'muledit_attributes'])
+        self.assertCountEqual(section_conf, ['main_hidden', 'muledit_attributes'])
         self.assertEqual(afk_get('CWUser', 'firstname', 'String', 'subject'), {'order': 1})
 
 
--- a/web/test/unittest_views_basecontrollers.py	Thu Oct 10 12:30:02 2013 +0200
+++ b/web/test/unittest_views_basecontrollers.py	Thu Aug 01 13:58:48 2013 +0200
@@ -397,7 +397,7 @@
         path, params = self.expect_redirect_handle_request(req, 'edit')
         usergroups = [gname for gname, in
                       self.execute('Any N WHERE G name N, U in_group G, U eid %(u)s', {'u': user.eid})]
-        self.assertItemsEqual(usergroups, ['managers', 'test'])
+        self.assertCountEqual(usergroups, ['managers', 'test'])
         self.assertEqual(get_pending_inserts(req), [])
 
     def test_req_pending_delete(self):
@@ -408,14 +408,14 @@
         usergroups = [gname for gname, in
                       self.execute('Any N WHERE G name N, U in_group G, U eid %(u)s', {'u': user.eid})]
         # just make sure everything was set correctly
-        self.assertItemsEqual(usergroups, ['managers', 'test'])
+        self.assertCountEqual(usergroups, ['managers', 'test'])
         # now try to delete the relation
         req = self.request(**req_form(user))
         req.session.data['pending_delete'] = set([(user.eid, 'in_group', groupeid)])
         path, params = self.expect_redirect_handle_request(req, 'edit')
         usergroups = [gname for gname, in
                       self.execute('Any N WHERE G name N, U in_group G, U eid %(u)s', {'u': user.eid})]
-        self.assertItemsEqual(usergroups, ['managers'])
+        self.assertCountEqual(usergroups, ['managers'])
         self.assertEqual(get_pending_deletes(req), [])
 
     def test_redirect_apply_button(self):
@@ -715,7 +715,7 @@
 
     def test_remote_add_existing_tag(self):
         self.remote_call('tag_entity', self.john.eid, ['python'])
-        self.assertItemsEqual(
+        self.assertCountEqual(
             [tname for tname, in self.execute('Any N WHERE T is Tag, T name N')],
             ['python', 'cubicweb'])
         self.assertEqual(
@@ -724,7 +724,7 @@
 
     def test_remote_add_new_tag(self):
         self.remote_call('tag_entity', self.john.eid, ['javascript'])
-        self.assertItemsEqual(
+        self.assertCountEqual(
             [tname for tname, in self.execute('Any N WHERE T is Tag, T name N')],
             ['python', 'cubicweb', 'javascript'])
         self.assertEqual(