summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_threading_local.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-04-01 09:56:39 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-04-01 09:56:39 (GMT)
commitbd8c629eb54860df775f0072f4cf5fbd23dededb (patch)
tree0b8ab1dc5a138c9b76a7d4eb138b62ee99dc0e16 /Lib/test/test_threading_local.py
parent2baaba8a95d6edfe205a6e61acc3b428705ee1fa (diff)
downloadcpython-bd8c629eb54860df775f0072f4cf5fbd23dededb.zip
cpython-bd8c629eb54860df775f0072f4cf5fbd23dededb.tar.gz
cpython-bd8c629eb54860df775f0072f4cf5fbd23dededb.tar.bz2
Issue #23799: Added test.test_support.start_threads() for running and
cleaning up multiple threads.
Diffstat (limited to 'Lib/test/test_threading_local.py')
-rw-r--r--Lib/test/test_threading_local.py19
1 files changed, 7 insertions, 12 deletions
diff --git a/Lib/test/test_threading_local.py b/Lib/test/test_threading_local.py
index 4c9f296..b161315 100644
--- a/Lib/test/test_threading_local.py
+++ b/Lib/test/test_threading_local.py
@@ -1,12 +1,12 @@
import unittest
from doctest import DocTestSuite
-from test import test_support
+from test import test_support as support
import weakref
import gc
# Modules under test
-_thread = test_support.import_module('thread')
-threading = test_support.import_module('threading')
+_thread = support.import_module('thread')
+threading = support.import_module('threading')
import _threading_local
@@ -63,14 +63,9 @@ class BaseLocalTest:
# Simply check that the variable is correctly set
self.assertEqual(local.x, i)
- threads= []
- for i in range(10):
- t = threading.Thread(target=f, args=(i,))
- t.start()
- threads.append(t)
-
- for t in threads:
- t.join()
+ with support.start_threads(threading.Thread(target=f, args=(i,))
+ for i in range(10)):
+ pass
def test_derived_cycle_dealloc(self):
# http://bugs.python.org/issue6990
@@ -228,7 +223,7 @@ def test_main():
setUp=setUp, tearDown=tearDown)
)
- test_support.run_unittest(suite)
+ support.run_unittest(suite)
if __name__ == '__main__':
test_main()