From 75f9d17638c9c6bec34f80326c35010c47924728 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Sun, 31 May 2015 07:10:45 -0400 Subject: Make Python tests more portable Newer Python versions randomize the hash seed for dictionaries, resulting in a random output order, which messes up the regression test diffs. Instead, use Python assert to compare the dictionaries with their expected value. --- contrib/hstore_plpython/sql/hstore_plpython.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'contrib/hstore_plpython/sql') diff --git a/contrib/hstore_plpython/sql/hstore_plpython.sql b/contrib/hstore_plpython/sql/hstore_plpython.sql index 872d8c621c0..9ff2ebcd833 100644 --- a/contrib/hstore_plpython/sql/hstore_plpython.sql +++ b/contrib/hstore_plpython/sql/hstore_plpython.sql @@ -37,7 +37,7 @@ CREATE FUNCTION test1arr(val hstore[]) RETURNS int LANGUAGE plpythonu TRANSFORM FOR TYPE hstore AS $$ -plpy.info(repr(val)) +assert(val == [{'aa': 'bb', 'cc': None}, {'dd': 'ee'}]) return len(val) $$; @@ -74,12 +74,12 @@ LANGUAGE plpythonu TRANSFORM FOR TYPE hstore AS $$ rv = plpy.execute("SELECT 'aa=>bb, cc=>NULL'::hstore AS col1") -plpy.info(repr(rv[0]["col1"])) +assert(rv[0]["col1"] == {'aa': 'bb', 'cc': None}) val = {'a': 1, 'b': 'boo', 'c': None} plan = plpy.prepare("SELECT $1::text AS col1", ["hstore"]) rv = plpy.execute(plan, [val]) -plpy.info(repr(rv[0]["col1"])) +assert(rv[0]["col1"] == '"a"=>"1", "b"=>"boo", "c"=>NULL') $$; SELECT test3(); @@ -94,7 +94,7 @@ CREATE FUNCTION test4() RETURNS trigger LANGUAGE plpythonu TRANSFORM FOR TYPE hstore AS $$ -plpy.info("Trigger row: {'a': %r, 'b': %r}" % (TD["new"]["a"], TD["new"]["b"])) +assert(TD["new"] == {'a': 1, 'b': {'aa': 'bb', 'cc': None}}) if TD["new"]["a"] == 1: TD["new"]["b"] = {'a': 1, 'b': 'boo', 'c': None} -- cgit v1.2.3