[Python-checkins] cpython (merge 3.3 -> default): Issue #14407: Fix unittest test discovery in test_concurrent_futures.

antoine.pitrou python-checkins at python.org
Tue Oct 15 23:24:58 CEST 2013


http://hg.python.org/cpython/rev/9cc40bc5f02b
changeset:   86383:9cc40bc5f02b
parent:      86381:2e8c424dc638
parent:      86382:38243a0a1f44
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Tue Oct 15 23:24:44 2013 +0200
summary:
  Issue #14407: Fix unittest test discovery in test_concurrent_futures.

files:
  Lib/test/test_concurrent_futures.py |  35 ++++++----------
  Misc/NEWS                           |   2 +
  2 files changed, 15 insertions(+), 22 deletions(-)


diff --git a/Lib/test/test_concurrent_futures.py b/Lib/test/test_concurrent_futures.py
--- a/Lib/test/test_concurrent_futures.py
+++ b/Lib/test/test_concurrent_futures.py
@@ -94,7 +94,7 @@
     executor_type = futures.ProcessPoolExecutor
 
 
-class ExecutorShutdownTest(unittest.TestCase):
+class ExecutorShutdownTest:
     def test_run_after_shutdown(self):
         self.executor.shutdown()
         self.assertRaises(RuntimeError,
@@ -122,7 +122,7 @@
             f.result()
 
 
-class ThreadPoolShutdownTest(ThreadPoolMixin, ExecutorShutdownTest):
+class ThreadPoolShutdownTest(ThreadPoolMixin, ExecutorShutdownTest, unittest.TestCase):
     def _prime_executor(self):
         pass
 
@@ -154,7 +154,7 @@
             t.join()
 
 
-class ProcessPoolShutdownTest(ProcessPoolMixin, ExecutorShutdownTest):
+class ProcessPoolShutdownTest(ProcessPoolMixin, ExecutorShutdownTest, unittest.TestCase):
     def _prime_executor(self):
         pass
 
@@ -190,7 +190,7 @@
             p.join()
 
 
-class WaitTests(unittest.TestCase):
+class WaitTests:
 
     def test_first_completed(self):
         future1 = self.executor.submit(mul, 21, 2)
@@ -291,7 +291,7 @@
         self.assertEqual(set([future2]), pending)
 
 
-class ThreadPoolWaitTests(ThreadPoolMixin, WaitTests):
+class ThreadPoolWaitTests(ThreadPoolMixin, WaitTests, unittest.TestCase):
 
     def test_pending_calls_race(self):
         # Issue #14406: multi-threaded race condition when waiting on all
@@ -309,11 +309,11 @@
             sys.setswitchinterval(oldswitchinterval)
 
 
-class ProcessPoolWaitTests(ProcessPoolMixin, WaitTests):
+class ProcessPoolWaitTests(ProcessPoolMixin, WaitTests, unittest.TestCase):
     pass
 
 
-class AsCompletedTests(unittest.TestCase):
+class AsCompletedTests:
     # TODO(brian at sweetapp.com): Should have a test with a non-zero timeout.
     def test_no_timeout(self):
         future1 = self.executor.submit(mul, 2, 21)
@@ -351,15 +351,15 @@
                          completed_futures)
 
 
-class ThreadPoolAsCompletedTests(ThreadPoolMixin, AsCompletedTests):
+class ThreadPoolAsCompletedTests(ThreadPoolMixin, AsCompletedTests, unittest.TestCase):
     pass
 
 
-class ProcessPoolAsCompletedTests(ProcessPoolMixin, AsCompletedTests):
+class ProcessPoolAsCompletedTests(ProcessPoolMixin, AsCompletedTests, unittest.TestCase):
     pass
 
 
-class ExecutorTest(unittest.TestCase):
+class ExecutorTest:
     # Executor.shutdown() and context manager usage is tested by
     # ExecutorShutdownTest.
     def test_submit(self):
@@ -419,7 +419,7 @@
                         "Stale reference not collected within timeout.")
 
 
-class ThreadPoolExecutorTest(ThreadPoolMixin, ExecutorTest):
+class ThreadPoolExecutorTest(ThreadPoolMixin, ExecutorTest, unittest.TestCase):
     def test_map_submits_without_iteration(self):
         """Tests verifying issue 11777."""
         finished = []
@@ -431,7 +431,7 @@
         self.assertCountEqual(finished, range(10))
 
 
-class ProcessPoolExecutorTest(ProcessPoolMixin, ExecutorTest):
+class ProcessPoolExecutorTest(ProcessPoolMixin, ExecutorTest, unittest.TestCase):
     def test_killed_child(self):
         # When a child process is abruptly terminated, the whole pool gets
         # "broken".
@@ -670,16 +670,7 @@
 @test.support.reap_threads
 def test_main():
     try:
-        test.support.run_unittest(ProcessPoolExecutorTest,
-                                  ThreadPoolExecutorTest,
-                                  ProcessPoolWaitTests,
-                                  ThreadPoolWaitTests,
-                                  ProcessPoolAsCompletedTests,
-                                  ThreadPoolAsCompletedTests,
-                                  FutureTests,
-                                  ProcessPoolShutdownTest,
-                                  ThreadPoolShutdownTest,
-                                  )
+        test.support.run_unittest(__name__)
     finally:
         test.support.reap_children()
 
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -116,6 +116,8 @@
 Tests
 -----
 
+- Issue #14407: Fix unittest test discovery in test_concurrent_futures.
+
 - Issue #18919: Unified and extended tests for audio modules: aifc, sunau and
   wave.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list