[dataimport] use next builtin instead of next method on iterators
authorJulien Cristau <julien.cristau@logilab.fr>
Wed, 21 Oct 2015 20:16:41 +0200
changeset 10855 cd91f46fa633
parent 10854 f437787d8849
child 10856 b839167d99a4
[dataimport] use next builtin instead of next method on iterators
dataimport/massive_store.py
dataimport/test/test_massive_store.py
--- a/dataimport/massive_store.py	Wed Oct 21 20:15:06 2015 +0200
+++ b/dataimport/massive_store.py	Wed Oct 21 20:16:41 2015 +0200
@@ -153,7 +153,7 @@
             self._cnx.system_sql(self._cnx.repo.system_source.dbhelper.sql_restart_numrange(
                 'entities_id_seq', initial_value=self._eids_seq_start + 1))
             cnx.commit()
-        self.get_next_eid = self._get_eid_gen().next
+        self.get_next_eid = lambda g=self._get_eid_gen(): next(g)
         # recreate then when self.cleanup() is called
         if not self.slave_mode and self.drop_index:
             self._drop_metatables_constraints()
--- a/dataimport/test/test_massive_store.py	Wed Oct 21 20:15:06 2015 +0200
+++ b/dataimport/test/test_massive_store.py	Wed Oct 21 20:16:41 2015 +0200
@@ -192,20 +192,20 @@
     def test_on_commit_callback(self):
         counter = itertools.count()
         with self.admin_access.repo_cnx() as cnx:
-            store = MassiveObjectStore(cnx, on_commit_callback=counter.next)
+            store = MassiveObjectStore(cnx, on_commit_callback=lambda:next(counter))
             store.create_entity('Location', name=u'toto')
             store.flush()
             store.commit()
-        self.assertTrue(counter.next() >= 1)
+        self.assertGreaterEqual(next(counter), 1)
 
     def test_on_rollback_callback(self):
         counter = itertools.count()
         with self.admin_access.repo_cnx() as cnx:
-            store = MassiveObjectStore(cnx, on_rollback_callback=lambda *_: counter.next())
+            store = MassiveObjectStore(cnx, on_rollback_callback=lambda *_: next(counter))
             store.create_entity('Location', nm='toto')
             store.flush()
             store.commit()
-        self.assertTrue(counter.next() >= 1)
+        self.assertGreaterEqual(next(counter), 1)
 
     def test_slave_mode_indexes(self):
         with self.admin_access.repo_cnx() as cnx: