PL/Python: Make tests pass with Python 3.5

The error message wording for AttributeError has changed in Python 3.5.
For the plpython_error test, add a new expected file.  In the
plpython_subtransaction test, we didn't really care what the exception
is, only that it is something coming from Python.  So use a generic
exception instead, which has a message that doesn't vary across
versions.
This commit is contained in:
Peter Eisentraut
2015-06-03 19:52:08 -04:00
parent d67616c743
commit f16d52269a
6 changed files with 445 additions and 16 deletions

View File

@ -19,7 +19,7 @@ try:
if what_error == "SPI":
plpy.execute("INSERT INTO subtransaction_tbl VALUES ('oops')")
elif what_error == "Python":
plpy.attribute_error
raise Exception("Python exception")
except:
exc = False
subxact.__exit__(*sys.exc_info())
@ -58,10 +58,10 @@ SELECT * FROM subtransaction_tbl;
TRUNCATE subtransaction_tbl;
SELECT subtransaction_test('Python');
ERROR: AttributeError: 'module' object has no attribute 'attribute_error'
ERROR: Exception: Python exception
CONTEXT: Traceback (most recent call last):
PL/Python function "subtransaction_test", line 13, in <module>
plpy.attribute_error
raise Exception("Python exception")
PL/Python function "subtransaction_test"
SELECT * FROM subtransaction_tbl;
i
@ -78,7 +78,7 @@ with plpy.subtransaction():
if what_error == "SPI":
plpy.execute("INSERT INTO subtransaction_tbl VALUES ('oops')")
elif what_error == "Python":
plpy.attribute_error
raise Exception("Python exception")
$$ LANGUAGE plpythonu;
ERROR: could not compile PL/Python function "subtransaction_ctx_test"
DETAIL: SyntaxError: invalid syntax (<string>, line 3)