Skip to content

Commit 6b5b85a

Browse files
vstinnergrzgrzgrz3
andauthored
bpo-30357: test_thread now uses threading_cleanup() (#1592) (#1622)
test_thread: setUp() now uses support.threading_setup() and support.threading_cleanup() to wait until threads complete to avoid random side effects on following tests. Co-Authored-By: Grzegorz Grzywacz <[email protected]> (cherry picked from commit 79ef7f8)
1 parent aaa0536 commit 6b5b85a

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

Lib/test/test_thread.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def verbose_print(arg):
2020
with _print_mutex:
2121
print(arg)
2222

23+
2324
class BasicThreadTest(unittest.TestCase):
2425

2526
def setUp(self):
@@ -31,6 +32,9 @@ def setUp(self):
3132
self.running = 0
3233
self.next_ident = 0
3334

35+
key = support.threading_setup()
36+
self.addCleanup(support.threading_cleanup, *key)
37+
3438

3539
class ThreadRunningTests(BasicThreadTest):
3640

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@ Eric Groo
551551
Daniel Andrade Groppe
552552
Dag Gruneau
553553
Filip Gruszczyński
554+
Grzegorz Grzywacz
554555
Thomas Guettler
555556
Yuyang Guo
556557
Anuj Gupta

Misc/NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ Tools/Demos
168168
Tests
169169
-----
170170

171+
* bpo-30357: test_thread: setUp() now uses support.threading_setup() and
172+
support.threading_cleanup() to wait until threads complete to avoid
173+
random side effects on following tests. Initial patch written by Grzegorz
174+
Grzywacz.
175+
171176
- bpo-30197: Enhanced functions swap_attr() and swap_item() in the
172177
test.support module. They now work when delete replaced attribute or item
173178
inside the with statement. The old value of the attribute or item (or None

0 commit comments

Comments
 (0)