◐ Shell
clean mode source ↗

[3.6] Test atexit shutdown mechanism in a subprocess (GH-4828) by pitrou · Pull Request #4829 · python/cpython

Expand Up @@ -3,6 +3,7 @@ import io import atexit from test import support from test.support import script_helper
### helpers def h1(): Expand Down Expand Up @@ -152,6 +153,21 @@ def test_bound_methods(self): atexit._run_exitfuncs() self.assertEqual(l, [5])
def test_shutdown(self): # Actually test the shutdown mechanism in a subprocess code = """if 1: import atexit
def f(msg): print(msg)
atexit.register(f, "one") atexit.register(f, "two") """ res = script_helper.assert_python_ok("-c", code) self.assertEqual(res.out.decode().splitlines(), ["two", "one"]) self.assertFalse(res.err)

@support.cpython_only class SubinterpreterTest(unittest.TestCase): Expand Down