diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-04-01 09:56:39 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-04-01 09:56:39 (GMT) |
commit | bd8c629eb54860df775f0072f4cf5fbd23dededb (patch) | |
tree | 0b8ab1dc5a138c9b76a7d4eb138b62ee99dc0e16 /Lib/test/test_threadedtempfile.py | |
parent | 2baaba8a95d6edfe205a6e61acc3b428705ee1fa (diff) | |
download | cpython-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_threadedtempfile.py')
-rw-r--r-- | Lib/test/test_threadedtempfile.py | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/Lib/test/test_threadedtempfile.py b/Lib/test/test_threadedtempfile.py index 81d9687..c2c30de 100644 --- a/Lib/test/test_threadedtempfile.py +++ b/Lib/test/test_threadedtempfile.py @@ -18,7 +18,7 @@ FILES_PER_THREAD = 50 import tempfile -from test.test_support import threading_setup, threading_cleanup, run_unittest, import_module +from test.test_support import start_threads, run_unittest, import_module threading = import_module('threading') import unittest import StringIO @@ -46,25 +46,12 @@ class TempFileGreedy(threading.Thread): class ThreadedTempFileTest(unittest.TestCase): def test_main(self): - threads = [] - thread_info = threading_setup() - - for i in range(NUM_THREADS): - t = TempFileGreedy() - threads.append(t) - t.start() - - startEvent.set() - - ok = 0 - errors = [] - for t in threads: - t.join() - ok += t.ok_count - if t.error_count: - errors.append(str(t.getName()) + str(t.errors.getvalue())) - - threading_cleanup(*thread_info) + threads = [TempFileGreedy() for i in range(NUM_THREADS)] + with start_threads(threads, startEvent.set): + pass + ok = sum(t.ok_count for t in threads) + errors = [str(t.getName()) + str(t.errors.getvalue()) + for t in threads if t.error_count] msg = "Errors: errors %d ok %d\n%s" % (len(errors), ok, '\n'.join(errors)) |