def test_iterator_chaining_respects_context_manager(self): i0 = InvocationGeneratorTests.TestIndexReader([1, 2, 3]) i1 = InvocationGeneratorTests.TestIndexReader([4, 5, 6]) self.assertEqual([1, 2, 3, 4, 5, 6], list(params.chain(i0, i1))) self.assertEqual(1, i0.enter_count) self.assertEqual(1, i0.exit_count) self.assertEqual(1, i1.enter_count) self.assertEqual(1, i1.exit_count)