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

Method test_atexit_with_unregistered_function

Lib/test/_test_atexit.py:121–136  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

119 self.assertEqual(l, [5])
120
121 def test_atexit_with_unregistered_function(self):
122 # See bpo-46025 for more info
123 def func():
124 atexit.unregister(func)
125 1/0
126 atexit.register(func)
127 try:
128 with support.catch_unraisable_exception() as cm:
129 atexit._run_exitfuncs()
130 self.assertIsNone(cm.unraisable.object)
131 self.assertEqual(cm.unraisable.err_msg,
132 f'Exception ignored in atexit callback {func!r}')
133 self.assertEqual(cm.unraisable.exc_type, ZeroDivisionError)
134 self.assertEqual(type(cm.unraisable.exc_value), ZeroDivisionError)
135 finally:
136 atexit.unregister(func)
137
138 def test_eq_unregister_clear(self):
139 # Issue #112127: callback's __eq__ may call unregister or _clear

Callers

nothing calls this directly

Calls 4

assertIsNoneMethod · 0.80
registerMethod · 0.45
assertEqualMethod · 0.45
unregisterMethod · 0.45

Tested by

no test coverage detected