Skip to content

Commit 79ef7f8

Browse files
vstinnergrzgrzgrz3
andauthored
bpo-30357: test_thread now uses threading_cleanup() (#1592)
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]>
1 parent 83a2c28 commit 79ef7f8

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
@@ -555,6 +555,7 @@ Eric Groo
555555
Daniel Andrade Groppe
556556
Dag Gruneau
557557
Filip Gruszczyński
558+
Grzegorz Grzywacz
558559
Thomas Guettler
559560
Yuyang Guo
560561
Anuj Gupta

Misc/NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,11 @@ Tools/Demos
11831183
Tests
11841184
-----
11851185

1186+
* bpo-30357: test_thread: setUp() now uses support.threading_setup() and
1187+
support.threading_cleanup() to wait until threads complete to avoid
1188+
random side effects on following tests. Initial patch written by Grzegorz
1189+
Grzywacz.
1190+
11861191
- bpo-30197: Enhanced functions swap_attr() and swap_item() in the
11871192
test.support module. They now work when delete replaced attribute or item
11881193
inside the with statement. The old value of the attribute or item (or None

0 commit comments

Comments
 (0)