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

Method test_is_finalizing

Lib/test/test_sys.py:1183–1202  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1181 self.assertTrue(sys._is_gil_enabled())
1182
1183 def test_is_finalizing(self):
1184 self.assertIs(sys.is_finalizing(), False)
1185 # Don't use the atexit module because _Py_Finalizing is only set
1186 # after calling atexit callbacks
1187 code = """if 1:
1188 import sys
1189
1190 class AtExit:
1191 is_finalizing = sys.is_finalizing
1192 print = print
1193
1194 def __del__(self):
1195 self.print(self.is_finalizing(), flush=True)
1196
1197 # Keep a reference in the __main__ module namespace, so the
1198 # AtExit destructor will be called at Python exit
1199 ref = AtExit()
1200 """
1201 rc, stdout, stderr = assert_python_ok('-c', code)
1202 self.assertEqual(stdout.rstrip(), b'True')
1203
1204 def test_issue20602(self):
1205 # sys.flags and sys.float_info were wiped during shutdown.

Callers

nothing calls this directly

Calls 4

assert_python_okFunction · 0.90
assertIsMethod · 0.45
assertEqualMethod · 0.45
rstripMethod · 0.45

Tested by

no test coverage detected