MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_empty_accessors

Method test_empty_accessors

test/sql/test_resultset.py:2062–2108  ·  view source on GitHub ↗
(self, connection)

Source from the content-addressed store, hash-verified

2060
2061 @testing.requires.selectone
2062 def test_empty_accessors(self, connection):
2063 statements = [
2064 (
2065 "select 1",
2066 [
2067 lambda r: r.last_inserted_params(),
2068 lambda r: r.last_updated_params(),
2069 lambda r: r.prefetch_cols(),
2070 lambda r: r.postfetch_cols(),
2071 lambda r: r.inserted_primary_key,
2072 ],
2073 "Statement is not a compiled expression construct.",
2074 ),
2075 (
2076 select(1),
2077 [
2078 lambda r: r.last_inserted_params(),
2079 lambda r: r.inserted_primary_key,
2080 ],
2081 r"Statement is not an insert\(\) expression construct.",
2082 ),
2083 (
2084 select(1),
2085 [lambda r: r.last_updated_params()],
2086 r"Statement is not an update\(\) expression construct.",
2087 ),
2088 (
2089 select(1),
2090 [lambda r: r.prefetch_cols(), lambda r: r.postfetch_cols()],
2091 r"Statement is not an insert\(\) "
2092 r"or update\(\) expression construct.",
2093 ),
2094 ]
2095
2096 for stmt, meths, msg in statements:
2097 if isinstance(stmt, str):
2098 r = connection.exec_driver_sql(stmt)
2099 else:
2100 r = connection.execute(stmt)
2101 try:
2102 for meth in meths:
2103 assert_raises_message(
2104 sa_exc.InvalidRequestError, msg, meth, r
2105 )
2106
2107 finally:
2108 r.close()
2109
2110 @testing.requires.dbapi_lastrowid
2111 def test_lastrowid(self, connection):

Callers

nothing calls this directly

Calls 9

selectFunction · 0.90
assert_raises_messageFunction · 0.90
last_inserted_paramsMethod · 0.80
last_updated_paramsMethod · 0.80
prefetch_colsMethod · 0.45
postfetch_colsMethod · 0.45
exec_driver_sqlMethod · 0.45
executeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected