Skip to content

Commit 43038b8

Browse files
committed
Add a test in test_atexit.
1 parent 3090524 commit 43038b8

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Lib/test/test_atexit.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,28 @@ def thready():
7979
# want them to affect the rest of the tests.
8080
script_helper.assert_python_ok("-c", textwrap.dedent(source))
8181

82+
@threading_helper.requires_working_threading()
83+
def test_thread_created_in_atexit(self):
84+
source = """
85+
import atexit
86+
import threading
87+
import time
88+
89+
90+
def run():
91+
print(24)
92+
time.sleep(1)
93+
print(42)
94+
95+
@atexit.register
96+
def start_thread():
97+
threading.Thread(target=run).start()
98+
"""
99+
100+
_, stdout, stderr = script_helper.assert_python_ok("-c", textwrap.dedent(source))
101+
self.assertEqual(stderr, b"")
102+
self.assertEqual(stdout, b"24\n42\n")
103+
82104

83105
@support.cpython_only
84106
class SubinterpreterTest(unittest.TestCase):

0 commit comments

Comments
 (0)