]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-30357: test_thread now uses threading_cleanup() (#1592) (#1622)
authorVictor Stinner <victor.stinner@gmail.com>
Wed, 17 May 2017 00:06:14 +0000 (17:06 -0700)
committerGitHub <noreply@github.com>
Wed, 17 May 2017 00:06:14 +0000 (17:06 -0700)
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>
(cherry picked from commit 79ef7f8e88a4972c4aecf95cfc5cd934f1861e08)

Lib/test/test_thread.py
Misc/ACKS
Misc/NEWS

index ef3059b68674b4d832dff9d38110eeee1505efe9..3909b75ccd4647d5e20de066f175227f1501cc6c 100644 (file)
@@ -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):
 
index 486b6e32850b885fac5177679ff7f3e8a65c836a..ccc9d2af3149c0b4185877eb3bac95a2e4ee6598 100644 (file)
--- 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
index 6a50c6265c5cf17e6ade2457c5f9f4bdc67aeca0..0459e8490048c9324d74f47b885b06de522336b9 100644 (file)
--- 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