Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 355dda8

Browse files
committed
Issue #14407: Fix unittest test discovery in test_concurrent_futures.
2 parents acc9f3f + 9816a1e commit 355dda8

2 files changed

Lines changed: 15 additions & 22 deletions

File tree

Lib/test/test_concurrent_futures.py

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class ProcessPoolMixin(ExecutorMixin):
9494
executor_type = futures.ProcessPoolExecutor
9595

9696

97-
class ExecutorShutdownTest(unittest.TestCase):
97+
class ExecutorShutdownTest:
9898
def test_run_after_shutdown(self):
9999
self.executor.shutdown()
100100
self.assertRaises(RuntimeError,
@@ -122,7 +122,7 @@ def test_hang_issue12364(self):
122122
f.result()
123123

124124

125-
class ThreadPoolShutdownTest(ThreadPoolMixin, ExecutorShutdownTest):
125+
class ThreadPoolShutdownTest(ThreadPoolMixin, ExecutorShutdownTest, unittest.TestCase):
126126
def _prime_executor(self):
127127
pass
128128

@@ -154,7 +154,7 @@ def test_del_shutdown(self):
154154
t.join()
155155

156156

157-
class ProcessPoolShutdownTest(ProcessPoolMixin, ExecutorShutdownTest):
157+
class ProcessPoolShutdownTest(ProcessPoolMixin, ExecutorShutdownTest, unittest.TestCase):
158158
def _prime_executor(self):
159159
pass
160160

@@ -190,7 +190,7 @@ def test_del_shutdown(self):
190190
p.join()
191191

192192

193-
class WaitTests(unittest.TestCase):
193+
class WaitTests:
194194

195195
def test_first_completed(self):
196196
future1 = self.executor.submit(mul, 21, 2)
@@ -291,7 +291,7 @@ def test_timeout(self):
291291
self.assertEqual(set([future2]), pending)
292292

293293

294-
class ThreadPoolWaitTests(ThreadPoolMixin, WaitTests):
294+
class ThreadPoolWaitTests(ThreadPoolMixin, WaitTests, unittest.TestCase):
295295

296296
def test_pending_calls_race(self):
297297
# Issue #14406: multi-threaded race condition when waiting on all
@@ -309,11 +309,11 @@ def future_func():
309309
sys.setswitchinterval(oldswitchinterval)
310310

311311

312-
class ProcessPoolWaitTests(ProcessPoolMixin, WaitTests):
312+
class ProcessPoolWaitTests(ProcessPoolMixin, WaitTests, unittest.TestCase):
313313
pass
314314

315315

316-
class AsCompletedTests(unittest.TestCase):
316+
class AsCompletedTests:
317317
# TODO([email protected]): Should have a test with a non-zero timeout.
318318
def test_no_timeout(self):
319319
future1 = self.executor.submit(mul, 2, 21)
@@ -351,15 +351,15 @@ def test_zero_timeout(self):
351351
completed_futures)
352352

353353

354-
class ThreadPoolAsCompletedTests(ThreadPoolMixin, AsCompletedTests):
354+
class ThreadPoolAsCompletedTests(ThreadPoolMixin, AsCompletedTests, unittest.TestCase):
355355
pass
356356

357357

358-
class ProcessPoolAsCompletedTests(ProcessPoolMixin, AsCompletedTests):
358+
class ProcessPoolAsCompletedTests(ProcessPoolMixin, AsCompletedTests, unittest.TestCase):
359359
pass
360360

361361

362-
class ExecutorTest(unittest.TestCase):
362+
class ExecutorTest:
363363
# Executor.shutdown() and context manager usage is tested by
364364
# ExecutorShutdownTest.
365365
def test_submit(self):
@@ -419,7 +419,7 @@ def test_no_stale_references(self):
419419
"Stale reference not collected within timeout.")
420420

421421

422-
class ThreadPoolExecutorTest(ThreadPoolMixin, ExecutorTest):
422+
class ThreadPoolExecutorTest(ThreadPoolMixin, ExecutorTest, unittest.TestCase):
423423
def test_map_submits_without_iteration(self):
424424
"""Tests verifying issue 11777."""
425425
finished = []
@@ -431,7 +431,7 @@ def record_finished(n):
431431
self.assertCountEqual(finished, range(10))
432432

433433

434-
class ProcessPoolExecutorTest(ProcessPoolMixin, ExecutorTest):
434+
class ProcessPoolExecutorTest(ProcessPoolMixin, ExecutorTest, unittest.TestCase):
435435
def test_killed_child(self):
436436
# When a child process is abruptly terminated, the whole pool gets
437437
# "broken".
@@ -670,16 +670,7 @@ def notification():
670670
@test.support.reap_threads
671671
def test_main():
672672
try:
673-
test.support.run_unittest(ProcessPoolExecutorTest,
674-
ThreadPoolExecutorTest,
675-
ProcessPoolWaitTests,
676-
ThreadPoolWaitTests,
677-
ProcessPoolAsCompletedTests,
678-
ThreadPoolAsCompletedTests,
679-
FutureTests,
680-
ProcessPoolShutdownTest,
681-
ThreadPoolShutdownTest,
682-
)
673+
test.support.run_unittest(__name__)
683674
finally:
684675
test.support.reap_children()
685676

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ Library
116116
Tests
117117
-----
118118

119+
- Issue #14407: Fix unittest test discovery in test_concurrent_futures.
120+
119121
- Issue #18919: Unified and extended tests for audio modules: aifc, sunau and
120122
wave.
121123

0 commit comments

Comments
 (0)