diff options
Diffstat (limited to 'test/engine/test_execute.py')
-rw-r--r-- | test/engine/test_execute.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/test/engine/test_execute.py b/test/engine/test_execute.py index 7ccd42b73..2b6dd1c09 100644 --- a/test/engine/test_execute.py +++ b/test/engine/test_execute.py @@ -896,6 +896,60 @@ class ResultProxyTest(fixtures.TestBase): writer.writerow(row) assert s.getvalue().strip() == '1,Test' + @testing.requires.selectone + def test_empty_accessors(self): + statements = [ + ( + "select 1", + [ + lambda r: r.last_inserted_params(), + lambda r: r.last_updated_params(), + lambda r: r.prefetch_cols(), + lambda r: r.postfetch_cols(), + lambda r : r.inserted_primary_key + ], + "Statement is not a compiled expression construct." + ), + ( + select([1]), + [ + lambda r: r.last_inserted_params(), + lambda r : r.inserted_primary_key + ], + r"Statement is not an insert\(\) expression construct." + ), + ( + select([1]), + [ + lambda r: r.last_updated_params(), + ], + r"Statement is not an update\(\) expression construct." + ), + ( + select([1]), + [ + lambda r: r.prefetch_cols(), + lambda r : r.postfetch_cols() + ], + r"Statement is not an insert\(\) " + r"or update\(\) expression construct." + ), + ] + + for stmt, meths, msg in statements: + r = testing.db.execute(stmt) + try: + for meth in meths: + assert_raises_message( + tsa.exc.InvalidRequestError, + msg, + meth, r + ) + + finally: + r.close() + + class AlternateResultProxyTest(fixtures.TestBase): __requires__ = ('sqlite', ) |