Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdb80507

Browse files
committed
Simplify some SPI tests of PL/Python
These tests relied on both next() and __next__(), but only the former isneeded since Python 2 support has been removed, so let's simplify a bitthe tests.Author: Erik WienholdDiscussion:https://postgr.es/m/173209043143.2092749.13692266486972491694@wrigleys.postgresql.org
1 parent2ff7c91 commitdb80507

File tree

2 files changed

+10
-36
lines changed

2 files changed

+10
-36
lines changed

‎src/pl/plpython/expected/plpython_spi.out

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,9 @@ assert len(res.fetch(3)) == 1
319319
assert len(res.fetch(3)) == 0
320320
assert len(res.fetch(3)) == 0
321321
try:
322-
# use next()or __next__(), the method name changed in
322+
# use next()and not __next__(), the method name changed in
323323
# http://www.python.org/dev/peps/pep-3114/
324-
try:
325-
res.next()
326-
except AttributeError:
327-
res.__next__()
324+
next(res)
328325
except StopIteration:
329326
pass
330327
else:
@@ -334,11 +331,7 @@ CREATE FUNCTION cursor_mix_next_and_fetch() RETURNS int AS $$
334331
res = plpy.cursor("select fname, lname from users order by fname")
335332
assert len(res.fetch(2)) == 2
336333

337-
item = None
338-
try:
339-
item = res.next()
340-
except AttributeError:
341-
item = res.__next__()
334+
item = next(res)
342335
assert item['fname'] == 'rick'
343336

344337
assert len(res.fetch(2)) == 1
@@ -357,10 +350,7 @@ CREATE FUNCTION next_after_close() RETURNS int AS $$
357350
res = plpy.cursor("select fname, lname from users")
358351
res.close()
359352
try:
360-
try:
361-
res.next()
362-
except AttributeError:
363-
res.__next__()
353+
next(res)
364354
except ValueError:
365355
pass
366356
else:
@@ -370,10 +360,7 @@ CREATE FUNCTION cursor_fetch_next_empty() RETURNS int AS $$
370360
res = plpy.cursor("select fname, lname from users where false")
371361
assert len(res.fetch(1)) == 0
372362
try:
373-
try:
374-
res.next()
375-
except AttributeError:
376-
res.__next__()
363+
next(res)
377364
except StopIteration:
378365
pass
379366
else:

‎src/pl/plpython/sql/plpython_spi.sql

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,9 @@ assert len(res.fetch(3)) == 1
218218
assert len(res.fetch(3))==0
219219
assert len(res.fetch(3))==0
220220
try:
221-
# use next()or __next__(), the method name changed in
221+
# use next()and not __next__(), the method name changed in
222222
# http://www.python.org/dev/peps/pep-3114/
223-
try:
224-
res.next()
225-
except AttributeError:
226-
res.__next__()
223+
next(res)
227224
except StopIteration:
228225
pass
229226
else:
@@ -234,11 +231,7 @@ CREATE FUNCTION cursor_mix_next_and_fetch() RETURNS int AS $$
234231
res=plpy.cursor("select fname, lname from users order by fname")
235232
assert len(res.fetch(2))==2
236233

237-
item= None
238-
try:
239-
item=res.next()
240-
except AttributeError:
241-
item=res.__next__()
234+
item= next(res)
242235
assert item['fname']=='rick'
243236

244237
assert len(res.fetch(2))==1
@@ -259,10 +252,7 @@ CREATE FUNCTION next_after_close() RETURNS int AS $$
259252
res=plpy.cursor("select fname, lname from users")
260253
res.close()
261254
try:
262-
try:
263-
res.next()
264-
except AttributeError:
265-
res.__next__()
255+
next(res)
266256
except ValueError:
267257
pass
268258
else:
@@ -273,10 +263,7 @@ CREATE FUNCTION cursor_fetch_next_empty() RETURNS int AS $$
273263
res=plpy.cursor("select fname, lname from users where false")
274264
assert len(res.fetch(1))==0
275265
try:
276-
try:
277-
res.next()
278-
except AttributeError:
279-
res.__next__()
266+
next(res)
280267
except StopIteration:
281268
pass
282269
else:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp