Skip to content

Commit 9b59ddf

Browse files
committed
It may not be obvious to you, but the plpython regression tests
include output that vary depending on the python build one is running. Basically, the order of keys in a dictionary is non-deterministic, and that part of the test fails for me regularly. I rewrote the test to work around this problem, and include a patch file with that change and the change to the expected otuput as well. Mike Meyer
1 parent c75d654 commit 9b59ddf

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/pl/plpython/feature.expected

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ select import_test_two(users) from users where fname = 'willem';
5454
(1 row)
5555

5656
select argument_test_one(users, fname, lname) from users where lname = 'doe' order by 1;
57-
argument_test_one
58-
-------------------------------------------------------------------------------------
59-
jane doe => {'fname': 'jane', 'userid': 1, 'lname': 'doe', 'username': 'j_doe'}
60-
john doe => {'fname': 'john', 'userid': 2, 'lname': 'doe', 'username': 'johnd'}
61-
willem doe => {'fname': 'willem', 'userid': 3, 'lname': 'doe', 'username': 'w_doe'}
57+
argument_test_one
58+
-----------------------------------------------------------------------
59+
jane doe => {fname: jane, lname: doe, userid: 1, username: j_doe}
60+
john doe => {fname: john, lname: doe, userid: 2, username: johnd}
61+
willem doe => {fname: willem, lname: doe, userid: 3, username: w_doe}
6262
(3 rows)
6363

6464
select nested_call_one('pass this along');

src/pl/plpython/plpython_function.sql

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,12 @@ return "sha hash of " + plain + " is " + digest.hexdigest()'
8282

8383
CREATE FUNCTION argument_test_one(users, text, text) RETURNS text
8484
AS
85-
'words = args[1] + " " + args[2] + " => " + str(args[0])
85+
'keys = args[0].keys()
86+
keys.sort()
87+
out = []
88+
for key in keys:
89+
out.append("%s: %s" % (key, args[0][key]))
90+
words = args[1] + " " + args[2] + " => {" + ", ".join(out) + "}"
8691
return words'
8792
LANGUAGE 'plpython';
8893

0 commit comments

Comments
 (0)