summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2017-12-01 19:53:30 -0800
committerJon Dufresne <jon.dufresne@gmail.com>2017-12-01 19:57:37 -0800
commitf5703dc3e55008b03aad4db8d8f3c5fa12dbae86 (patch)
treeafbb7a1f165ddf529fc95376397dfa02bee383c8 /tests
parenta51160317c680662c52e4a1a6b4d11beae37f205 (diff)
downloadpsycopg2-f5703dc3e55008b03aad4db8d8f3c5fa12dbae86.tar.gz
Use builtin function next() throughout project
Available since Python 2.6. Use of .next() is deprecated and not supported in Python 3. Forward compatible with modern Python. https://docs.python.org/2/library/functions.html#next
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test_cursor.py4
-rwxr-xr-xtests/test_extras_dictcursor.py8
-rwxr-xr-xtests/test_sql.py6
3 files changed, 9 insertions, 9 deletions
diff --git a/tests/test_cursor.py b/tests/test_cursor.py
index c5ce70f..6772bfe 100755
--- a/tests/test_cursor.py
+++ b/tests/test_cursor.py
@@ -334,9 +334,9 @@ class CursorTests(ConnectingTestCase):
# timestamp will not be influenced by the pause in Python world.
curs.execute("""select clock_timestamp() from generate_series(1,2)""")
i = iter(curs)
- t1 = (i.next())[0] # the brackets work around a 2to3 bug
+ t1 = next(i)[0]
time.sleep(0.2)
- t2 = (i.next())[0]
+ t2 = next(i)[0]
self.assert_((t2 - t1).microseconds * 1e-6 < 0.1,
"named cursor records fetched in 2 roundtrips (delta: %s)"
% (t2 - t1))
diff --git a/tests/test_extras_dictcursor.py b/tests/test_extras_dictcursor.py
index 2c867d3..e95c923 100755
--- a/tests/test_extras_dictcursor.py
+++ b/tests/test_extras_dictcursor.py
@@ -310,22 +310,22 @@ class NamedTupleCursorTest(ConnectingTestCase):
i = iter(curs)
self.assertEqual(curs.rownumber, 0)
- t = i.next()
+ t = next(i)
self.assertEqual(t.i, 1)
self.assertEqual(t.s, 'foo')
self.assertEqual(curs.rownumber, 1)
self.assertEqual(curs.rowcount, 3)
- t = i.next()
+ t = next(i)
self.assertEqual(t.i, 2)
self.assertEqual(t.s, 'bar')
self.assertEqual(curs.rownumber, 2)
self.assertEqual(curs.rowcount, 3)
- t = i.next()
+ t = next(i)
self.assertEqual(t.i, 3)
self.assertEqual(t.s, 'baz')
- self.assertRaises(StopIteration, i.next)
+ self.assertRaises(StopIteration, next, i)
self.assertEqual(curs.rownumber, 3)
self.assertEqual(curs.rowcount, 3)
diff --git a/tests/test_sql.py b/tests/test_sql.py
index 2e12ba6..08f43b4 100755
--- a/tests/test_sql.py
+++ b/tests/test_sql.py
@@ -344,11 +344,11 @@ class ComposedTest(ConnectingTestCase):
def test_iter(self):
obj = sql.Composed([sql.SQL("foo"), sql.SQL('bar')])
it = iter(obj)
- i = it.next()
+ i = next(it)
self.assertEqual(i, sql.SQL('foo'))
- i = it.next()
+ i = next(it)
self.assertEqual(i, sql.SQL('bar'))
- self.assertRaises(StopIteration, it.next)
+ self.assertRaises(StopIteration, next, it)
class PlaceholderTest(ConnectingTestCase):