MCPcopy Index your code
hub / github.com/python/cpython / test_closing_error

Method test_closing_error

Lib/test/test_contextlib.py:419–430  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

417 self.assertEqual(state, [1])
418
419 def test_closing_error(self):
420 state = []
421 class C:
422 def close(self):
423 state.append(1)
424 x = C()
425 self.assertEqual(state, [])
426 with self.assertRaises(ZeroDivisionError):
427 with closing(x) as y:
428 self.assertEqual(x, y)
429 1 / 0
430 self.assertEqual(state, [1])
431
432
433class NullcontextTestCase(unittest.TestCase):

Callers

nothing calls this directly

Calls 4

closingClass · 0.85
CClass · 0.70
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected