# HG changeset patch # User Julien Cristau # Date 1445451401 -7200 # Node ID cd91f46fa6338cd69d38c0ebf5d16914fe73deb9 # Parent f437787d8849bc9ddcc032207f18a5f8be644d7f [dataimport] use next builtin instead of next method on iterators diff -r f437787d8849 -r cd91f46fa633 dataimport/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() diff -r f437787d8849 -r cd91f46fa633 dataimport/test/test_massive_store.py --- 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: