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

Method _test_proxy

test/sql/test_resultset.py:3170–3220  ·  view source on GitHub ↗
(self, cls)

Source from the content-addressed store, hash-verified

3168 yield
3169
3170 def _test_proxy(self, cls):
3171 with self._proxy_fixture(cls):
3172 rows = []
3173 with self.engine.connect() as conn:
3174 r = conn.execute(select(self.table))
3175 assert isinstance(r.cursor_strategy, cls)
3176 for i in range(5):
3177 rows.append(r.fetchone())
3178 eq_(rows, [(i, "t_%d" % i) for i in range(1, 6)])
3179
3180 rows = r.fetchmany(3)
3181 eq_(rows, [(i, "t_%d" % i) for i in range(6, 9)])
3182
3183 rows = r.fetchall()
3184 eq_(rows, [(i, "t_%d" % i) for i in range(9, 12)])
3185
3186 r = conn.execute(select(self.table))
3187 rows = r.fetchmany(None)
3188 eq_(rows[0], (1, "t_1"))
3189 # number of rows here could be one, or the whole thing
3190 assert len(rows) == 1 or len(rows) == 11
3191
3192 r = conn.execute(select(self.table).limit(1))
3193 r.fetchone()
3194 eq_(r.fetchone(), None)
3195
3196 r = conn.execute(select(self.table).limit(5))
3197 rows = r.fetchmany(6)
3198 eq_(rows, [(i, "t_%d" % i) for i in range(1, 6)])
3199
3200 # result keeps going just fine with blank results...
3201 eq_(r.fetchmany(2), [])
3202
3203 eq_(r.fetchmany(2), [])
3204
3205 eq_(r.fetchall(), [])
3206
3207 eq_(r.fetchone(), None)
3208
3209 # until we close
3210 r.close()
3211
3212 self._assert_result_closed(r)
3213
3214 r = conn.execute(select(self.table).limit(5))
3215 eq_(r.first(), (1, "t_1"))
3216 self._assert_result_closed(r)
3217
3218 r = conn.execute(select(self.table).limit(5))
3219 eq_(r.scalar(), 1)
3220 self._assert_result_closed(r)
3221
3222 def _assert_result_closed(self, r):
3223 assert_raises_message(

Calls 14

_proxy_fixtureMethod · 0.95
_assert_result_closedMethod · 0.95
selectFunction · 0.90
eq_Function · 0.90
connectMethod · 0.45
executeMethod · 0.45
appendMethod · 0.45
fetchoneMethod · 0.45
fetchmanyMethod · 0.45
fetchallMethod · 0.45
limitMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected