MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_freeze

Method test_freeze

test/sql/test_resultset.py:114–155  ·  view source on GitHub ↗

test #8963

(self, type_, connection)

Source from the content-addressed store, hash-verified

112 "type_", ["text", "driversql", "core", "textstar", "driverstar"]
113 )
114 def test_freeze(self, type_, connection):
115 """test #8963"""
116
117 users = self.tables.users
118 connection.execute(
119 users.insert(),
120 [
121 dict(user_id=1, user_name="john"),
122 dict(user_id=2, user_name="jack"),
123 ],
124 )
125
126 if type_.core:
127 stmt = select(users).order_by(users.c.user_id)
128 else:
129 if "star" in type_.name:
130 stmt = "select * from users order by user_id"
131 else:
132 stmt = "select user_id, user_name from users order by user_id"
133
134 if "text" in type_.name:
135 stmt = text(stmt)
136
137 if "driver" in type_.name:
138 result = connection.exec_driver_sql(stmt)
139 else:
140 result = connection.execute(stmt)
141
142 frozen = result.freeze()
143
144 unfrozen = frozen()
145 eq_(unfrozen.keys(), ["user_id", "user_name"])
146 eq_(unfrozen.all(), [(1, "john"), (2, "jack")])
147
148 unfrozen = frozen()
149 eq_(
150 unfrozen.mappings().all(),
151 [
152 {"user_id": 1, "user_name": "john"},
153 {"user_id": 2, "user_name": "jack"},
154 ],
155 )
156
157 @testing.requires.insert_executemany_returning
158 def test_splice_horizontally(self, connection):

Callers

nothing calls this directly

Calls 11

selectFunction · 0.90
textFunction · 0.90
eq_Function · 0.90
executeMethod · 0.45
insertMethod · 0.45
order_byMethod · 0.45
exec_driver_sqlMethod · 0.45
freezeMethod · 0.45
keysMethod · 0.45
allMethod · 0.45
mappingsMethod · 0.45

Tested by

no test coverage detected