From: Victor Stinner Date: Wed, 17 May 2017 00:06:14 +0000 (-0700) Subject: bpo-30357: test_thread now uses threading_cleanup() (#1592) (#1622) X-Git-Tag: v3.6.2rc1~150 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6b5b85aecf4db796a05582202a6c875b36eae516;p=thirdparty%2FPython%2Fcpython.git 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 (cherry picked from commit 79ef7f8e88a4972c4aecf95cfc5cd934f1861e08) --- diff --git a/Lib/test/test_thread.py b/Lib/test/test_thread.py index ef3059b68674..3909b75ccd46 100644 --- a/Lib/test/test_thread.py +++ b/Lib/test/test_thread.py @@ -20,6 +20,7 @@ def verbose_print(arg): with _print_mutex: print(arg) + class BasicThreadTest(unittest.TestCase): def setUp(self): @@ -31,6 +32,9 @@ class BasicThreadTest(unittest.TestCase): self.running = 0 self.next_ident = 0 + key = support.threading_setup() + self.addCleanup(support.threading_cleanup, *key) + class ThreadRunningTests(BasicThreadTest): diff --git a/Misc/ACKS b/Misc/ACKS index 486b6e32850b..ccc9d2af3149 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -551,6 +551,7 @@ Eric Groo Daniel Andrade Groppe Dag Gruneau Filip Gruszczyński +Grzegorz Grzywacz Thomas Guettler Yuyang Guo Anuj Gupta diff --git a/Misc/NEWS b/Misc/NEWS index 6a50c6265c5c..0459e8490048 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -168,6 +168,11 @@ Tools/Demos 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 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