(self)
| 770 | 1/0 |
| 771 | |
| 772 | def test_enter_context(self): |
| 773 | class TestCM(object): |
| 774 | def __enter__(self): |
| 775 | result.append(1) |
| 776 | def __exit__(self, *exc_details): |
| 777 | result.append(3) |
| 778 | |
| 779 | result = [] |
| 780 | cm = TestCM() |
| 781 | with self.exit_stack() as stack: |
| 782 | @stack.callback # Registered first => cleaned up last |
| 783 | def _exit(): |
| 784 | result.append(4) |
| 785 | self.assertIsNotNone(_exit) |
| 786 | stack.enter_context(cm) |
| 787 | self.assertIs(stack._exit_callbacks[-1][1].__self__, cm) |
| 788 | result.append(2) |
| 789 | self.assertEqual(result, [1, 2, 3, 4]) |
| 790 | |
| 791 | def test_enter_context_classmethod(self): |
| 792 | class TestCM: |
nothing calls this directly
no test coverage detected