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 <grzegorz.grzywacz@nazwa.pl>
This commit is contained in:
Victor Stinner 2017-05-15 17:55:32 +02:00 committed by GitHub
parent 83a2c28798
commit 79ef7f8e88
3 changed files with 10 additions and 0 deletions

View file

@ -20,6 +20,7 @@ def verbose_print(arg):
with _print_mutex: with _print_mutex:
print(arg) print(arg)
class BasicThreadTest(unittest.TestCase): class BasicThreadTest(unittest.TestCase):
def setUp(self): def setUp(self):
@ -31,6 +32,9 @@ class BasicThreadTest(unittest.TestCase):
self.running = 0 self.running = 0
self.next_ident = 0 self.next_ident = 0
key = support.threading_setup()
self.addCleanup(support.threading_cleanup, *key)
class ThreadRunningTests(BasicThreadTest): class ThreadRunningTests(BasicThreadTest):

View file

@ -555,6 +555,7 @@ Eric Groo
Daniel Andrade Groppe Daniel Andrade Groppe
Dag Gruneau Dag Gruneau
Filip Gruszczyński Filip Gruszczyński
Grzegorz Grzywacz
Thomas Guettler Thomas Guettler
Yuyang Guo Yuyang Guo
Anuj Gupta Anuj Gupta

View file

@ -1183,6 +1183,11 @@ Tools/Demos
Tests Tests
----- -----
* bpo-30357: 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. Initial patch written by Grzegorz
Grzywacz.
- bpo-30197: Enhanced functions swap_attr() and swap_item() in the - bpo-30197: Enhanced functions swap_attr() and swap_item() in the
test.support module. They now work when delete replaced attribute or item test.support module. They now work when delete replaced attribute or item
inside the with statement. The old value of the attribute or item (or None inside the with statement. The old value of the attribute or item (or None