| 1245 | ) |
| 1246 | @async_test |
| 1247 | async def test_aiter(self, async_engine, filter_): |
| 1248 | users = self.tables.users |
| 1249 | async with async_engine.connect() as conn: |
| 1250 | if filter_ == "stream_scalars": |
| 1251 | result = await conn.stream_scalars(select(users.c.user_name)) |
| 1252 | else: |
| 1253 | result = await conn.stream(select(users)) |
| 1254 | |
| 1255 | if filter_ == "mappings": |
| 1256 | result = result.mappings() |
| 1257 | elif filter_ == "scalars": |
| 1258 | result = result.scalars(1) |
| 1259 | |
| 1260 | rows = [] |
| 1261 | |
| 1262 | async for row in result: |
| 1263 | rows.append(row) |
| 1264 | |
| 1265 | if filter_ == "mappings": |
| 1266 | eq_( |
| 1267 | rows, |
| 1268 | [ |
| 1269 | {"user_id": i, "user_name": "name%d" % i} |
| 1270 | for i in range(1, 20) |
| 1271 | ], |
| 1272 | ) |
| 1273 | elif filter_ in ("scalars", "stream_scalars"): |
| 1274 | eq_( |
| 1275 | rows, |
| 1276 | ["name%d" % i for i in range(1, 20)], |
| 1277 | ) |
| 1278 | else: |
| 1279 | eq_(rows, [(i, "name%d" % i) for i in range(1, 20)]) |
| 1280 | |
| 1281 | @testing.combinations((None,), ("mappings",), argnames="filter_") |
| 1282 | @async_test |