1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-12 02:37:31 +03:00

PL/Python: Adjust the regression tests for Python 3.3

The string representation of ImportError changed.  Remove printing
that; it's not necessary for the test.

The order in which members of a dict are printed changed.  But this
was always implementation-dependent, so we have just been lucky for a
long time.  Do the printing the hard way to ensure sorted order.
This commit is contained in:
Peter Eisentraut
2012-05-11 23:01:15 +03:00
parent 63fecc9177
commit 2cfb1c6f77
6 changed files with 38 additions and 16 deletions

View File

@@ -4,8 +4,7 @@ CREATE FUNCTION import_fail() returns text
AS
'try:
import foosocket
except Exception, ex:
plpy.notice("import socket failed -- %s" % str(ex))
except ImportError:
return "failed as expected"
return "succeeded, that wasn''t supposed to happen"'
LANGUAGE plpythonu;

View File

@@ -14,7 +14,14 @@ $$ LANGUAGE plpythonu;
CREATE FUNCTION test_param_names2(u users) RETURNS text AS $$
assert u == args[0]
return str(u)
if isinstance(u, dict):
# stringify dict the hard way because otherwise the order is implementation-dependent
u_keys = list(u.keys())
u_keys.sort()
s = '{' + ', '.join([repr(k) + ': ' + repr(u[k]) for k in u_keys]) + '}'
else:
s = str(u)
return s
$$ LANGUAGE plpythonu;
-- use deliberately wrong parameter names

View File

@@ -75,8 +75,14 @@ if 'relid' in TD:
skeys = list(TD.keys())
skeys.sort()
for key in skeys:
val = TD[key]
plpy.notice("TD[" + key + "] => " + str(val))
val = TD[key]
if not isinstance(val, dict):
plpy.notice("TD[" + key + "] => " + str(val))
else:
# print dicts the hard way because otherwise the order is implementation-dependent
valkeys = list(val.keys())
valkeys.sort()
plpy.notice("TD[" + key + "] => " + '{' + ', '.join([repr(k) + ': ' + repr(val[k]) for k in valkeys]) + '}')
return None