diff options
author | Antoine Pitrou <pitrou@free.fr> | 2017-12-13 10:53:59 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-13 10:53:59 (GMT) |
commit | b6263ca313d9806a4b7f1a3a3441d54e6338cc94 (patch) | |
tree | e0d3a3cd67c0f0b8ed6a2c144466165c051f2fb4 | |
parent | b0358e8784821867ab05b3d890717c37309be849 (diff) | |
download | cpython-b6263ca313d9806a4b7f1a3a3441d54e6338cc94.zip cpython-b6263ca313d9806a4b7f1a3a3441d54e6338cc94.tar.gz cpython-b6263ca313d9806a4b7f1a3a3441d54e6338cc94.tar.bz2 |
[3.6] Test atexit shutdown mechanism in a subprocess (GH-4828) (#4829)
* Test atexit shutdown mechanism in a subprocess.
(cherry picked from commit fc5db95e0063eafa2bfb7f487fcaad5a7c4b65a1)
-rw-r--r-- | Lib/test/test_atexit.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_atexit.py b/Lib/test/test_atexit.py index 1d0b018..aa56388 100644 --- a/Lib/test/test_atexit.py +++ b/Lib/test/test_atexit.py @@ -3,6 +3,7 @@ import unittest import io import atexit from test import support +from test.support import script_helper ### helpers def h1(): @@ -152,6 +153,21 @@ class GeneralTest(unittest.TestCase): 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): |