| 353 | eq_(row._mapping["anon_2"], 10) |
| 354 | |
| 355 | def test_row_comparison(self, connection): |
| 356 | users = self.tables.users |
| 357 | |
| 358 | connection.execute(users.insert(), dict(user_id=7, user_name="jack")) |
| 359 | rp = connection.execute(users.select()).first() |
| 360 | |
| 361 | eq_(rp, rp) |
| 362 | is_(not (rp != rp), True) |
| 363 | |
| 364 | equal = (7, "jack") |
| 365 | |
| 366 | eq_(rp, equal) |
| 367 | eq_(equal, rp) |
| 368 | is_((not (rp != equal)), True) |
| 369 | is_(not (equal != equal), True) |
| 370 | |
| 371 | def endless(): |
| 372 | while True: |
| 373 | yield 1 |
| 374 | |
| 375 | ne_(rp, endless()) |
| 376 | ne_(endless(), rp) |
| 377 | |
| 378 | # test that everything compares the same |
| 379 | # as it would against a tuple |
| 380 | for compare in [False, 8, endless(), "xyz", (7, "jack")]: |
| 381 | for op in [ |
| 382 | operator.eq, |
| 383 | operator.ne, |
| 384 | operator.gt, |
| 385 | operator.lt, |
| 386 | operator.ge, |
| 387 | operator.le, |
| 388 | ]: |
| 389 | try: |
| 390 | control = op(equal, compare) |
| 391 | except TypeError: |
| 392 | # Py3K raises TypeError for some invalid comparisons |
| 393 | assert_raises(TypeError, op, rp, compare) |
| 394 | else: |
| 395 | eq_(control, op(rp, compare)) |
| 396 | |
| 397 | try: |
| 398 | control = op(compare, equal) |
| 399 | except TypeError: |
| 400 | # Py3K raises TypeError for some invalid comparisons |
| 401 | assert_raises(TypeError, op, compare, rp) |
| 402 | else: |
| 403 | eq_(control, op(compare, rp)) |
| 404 | |
| 405 | @testing.provide_metadata |
| 406 | def test_column_label_overlap_fallback(self, connection): |