Skip to content

Commit 9816a1e

Browse files
committed
Issue #14407: Fix unittest test discovery in test_concurrent_futures.
1 parent b46fe79 commit 9816a1e

File tree

2 files changed

+15
-22
lines changed

2 files changed

+15
-22
lines changed

Lib/test/test_concurrent_futures.py

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

9090

91-
class ExecutorShutdownTest(unittest.TestCase):
91+
class ExecutorShutdownTest:
9292
def test_run_after_shutdown(self):
9393
self.executor.shutdown()
9494
self.assertRaises(RuntimeError,
@@ -116,7 +116,7 @@ def test_hang_issue12364(self):
116116
f.result()
117117

118118

119-
class ThreadPoolShutdownTest(ThreadPoolMixin, ExecutorShutdownTest):
119+
class ThreadPoolShutdownTest(ThreadPoolMixin, ExecutorShutdownTest, unittest.TestCase):
120120
def _prime_executor(self):
121121
pass
122122

@@ -148,7 +148,7 @@ def test_del_shutdown(self):
148148
t.join()
149149

150150

151-
class ProcessPoolShutdownTest(ProcessPoolMixin, ExecutorShutdownTest):
151+
class ProcessPoolShutdownTest(ProcessPoolMixin, ExecutorShutdownTest, unittest.TestCase):
152152
def _prime_executor(self):
153153
pass
154154

@@ -184,7 +184,7 @@ def test_del_shutdown(self):
184184
p.join()
185185

186186

187-
class WaitTests(unittest.TestCase):
187+
class WaitTests:
188188

189189
def test_first_completed(self):
190190
future1 = self.executor.submit(mul, 21, 2)
@@ -285,7 +285,7 @@ def test_timeout(self):
285285
self.assertEqual(set([future2]), pending)
286286

287287

288-
class ThreadPoolWaitTests(ThreadPoolMixin, WaitTests):
288+
class ThreadPoolWaitTests(ThreadPoolMixin, WaitTests, unittest.TestCase):
289289

290290
def test_pending_calls_race(self):
291291
# Issue #14406: multi-threaded race condition when waiting on all
@@ -303,11 +303,11 @@ def future_func():
303303
sys.setswitchinterval(oldswitchinterval)
304304

305305

306-
class ProcessPoolWaitTests(ProcessPoolMixin, WaitTests):
306+
class ProcessPoolWaitTests(ProcessPoolMixin, WaitTests, unittest.TestCase):
307307
pass
308308

309309

310-
class AsCompletedTests(unittest.TestCase):
310+
class AsCompletedTests:
311311
# TODO(brian@sweetapp.com): Should have a test with a non-zero timeout.
312312
def test_no_timeout(self):
313313
future1 = self.executor.submit(mul, 2, 21)
@@ -345,15 +345,15 @@ def test_zero_timeout(self):
345345
completed_futures)
346346

347347

348-
class ThreadPoolAsCompletedTests(ThreadPoolMixin, AsCompletedTests):
348+
class ThreadPoolAsCompletedTests(ThreadPoolMixin, AsCompletedTests, unittest.TestCase):
349349
pass
350350

351351

352-
class ProcessPoolAsCompletedTests(ProcessPoolMixin, AsCompletedTests):
352+
class ProcessPoolAsCompletedTests(ProcessPoolMixin, AsCompletedTests, unittest.TestCase):
353353
pass
354354

355355

356-
class ExecutorTest(unittest.TestCase):
356+
class ExecutorTest:
357357
# Executor.shutdown() and context manager usage is tested by
358358
# ExecutorShutdownTest.
359359
def test_submit(self):
@@ -397,7 +397,7 @@ def test_shutdown_race_issue12456(self):
397397
self.executor.shutdown()
398398

399399

400-
class ThreadPoolExecutorTest(ThreadPoolMixin, ExecutorTest):
400+
class ThreadPoolExecutorTest(ThreadPoolMixin, ExecutorTest, unittest.TestCase):
401401
def test_map_submits_without_iteration(self):
402402
"""Tests verifying issue 11777."""
403403
finished = []
@@ -409,7 +409,7 @@ def record_finished(n):
409409
self.assertCountEqual(finished, range(10))
410410

411411

412-
class ProcessPoolExecutorTest(ProcessPoolMixin, ExecutorTest):
412+
class ProcessPoolExecutorTest(ProcessPoolMixin, ExecutorTest, unittest.TestCase):
413413
def test_killed_child(self):
414414
# When a child process is abruptly terminated, the whole pool gets
415415
# "broken".
@@ -648,16 +648,7 @@ def notification():
648648
@test.support.reap_threads
649649
def test_main():
650650
try:
651-
test.support.run_unittest(ProcessPoolExecutorTest,
652-
ThreadPoolExecutorTest,
653-
ProcessPoolWaitTests,
654-
ThreadPoolWaitTests,
655-
ProcessPoolAsCompletedTests,
656-
ThreadPoolAsCompletedTests,
657-
FutureTests,
658-
ProcessPoolShutdownTest,
659-
ThreadPoolShutdownTest,
660-
)
651+
test.support.run_unittest(__name__)
661652
finally:
662653
test.support.reap_children()
663654

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,8 @@ IDLE
430430
Tests
431431
-----
432432

433+
- Issue #14407: Fix unittest test discovery in test_concurrent_futures.
434+
433435
- Issue #18919: Unified and extended tests for audio modules: aifc, sunau and
434436
wave.
435437

0 commit comments

Comments
 (0)