(self)
| 542 | |
| 543 | @_async_test |
| 544 | async def test_async_callback(self): |
| 545 | expected = [ |
| 546 | ((), {}), |
| 547 | ((1,), {}), |
| 548 | ((1,2), {}), |
| 549 | ((), dict(example=1)), |
| 550 | ((1,), dict(example=1)), |
| 551 | ((1,2), dict(example=1)), |
| 552 | ] |
| 553 | result = [] |
| 554 | async def _exit(*args, **kwds): |
| 555 | """Test metadata propagation""" |
| 556 | result.append((args, kwds)) |
| 557 | |
| 558 | async with AsyncExitStack() as stack: |
| 559 | for args, kwds in reversed(expected): |
| 560 | if args and kwds: |
| 561 | f = stack.push_async_callback(_exit, *args, **kwds) |
| 562 | elif args: |
| 563 | f = stack.push_async_callback(_exit, *args) |
| 564 | elif kwds: |
| 565 | f = stack.push_async_callback(_exit, **kwds) |
| 566 | else: |
| 567 | f = stack.push_async_callback(_exit) |
| 568 | self.assertIs(f, _exit) |
| 569 | for wrapper in stack._exit_callbacks: |
| 570 | self.assertIs(wrapper[1].__wrapped__, _exit) |
| 571 | self.assertNotEqual(wrapper[1].__name__, _exit.__name__) |
| 572 | self.assertIsNone(wrapper[1].__doc__, _exit.__doc__) |
| 573 | |
| 574 | self.assertEqual(result, expected) |
| 575 | |
| 576 | result = [] |
| 577 | async with AsyncExitStack() as stack: |
| 578 | with self.assertRaises(TypeError): |
| 579 | stack.push_async_callback(arg=1) |
| 580 | with self.assertRaises(TypeError): |
| 581 | self.exit_stack.push_async_callback(arg=2) |
| 582 | with self.assertRaises(TypeError): |
| 583 | stack.push_async_callback(callback=_exit, arg=3) |
| 584 | self.assertEqual(result, []) |
| 585 | |
| 586 | @_async_test |
| 587 | async def test_async_push(self): |
nothing calls this directly
no test coverage detected