@@ -66,7 +66,7 @@ def make_dummy_object(_):
6666 return MyObject ()
6767
6868
69- class BaseTestCase (BaseTestCase ):
69+ class BaseTestCase (unittest . TestCase ):
7070 def setUp (self ):
7171 self ._thread_key = test .support .threading_setup ()
7272
@@ -83,7 +83,13 @@ def setUp(self):
8383
8484 self .t1 = time .time ()
8585 try :
86- self .executor = self .executor_type (max_workers = self .worker_count )
86+ if hasattr (self , "ctx" ):
87+ self .executor = self .executor_type (
88+ max_workers = self .worker_count ,
89+ ctx = get_context (self .ctx ))
90+ else :
91+ self .executor = self .executor_type (
92+ max_workers = self .worker_count )
8793 except NotImplementedError as e :
8894 self .skipTest (str (e ))
8995 self ._prime_executor ()
@@ -113,21 +119,8 @@ class ThreadPoolMixin(ExecutorMixin):
113119 executor_type = futures .ThreadPoolExecutor
114120
115121
116- class ProcessPoolMixin (ExecutorMixin ):
122+ class ProcessPoolForkMixin (ExecutorMixin ):
117123 executor_type = futures .ProcessPoolExecutor
118-
119- def setUp (self ):
120- self .t1 = time .time ()
121- try :
122- self .executor = self .executor_type (
123- max_workers = self .worker_count ,
124- ctx = get_context (self .ctx ))
125- except NotImplementedError as e :
126- self .skipTest (str (e ))
127- self ._prime_executor ()
128-
129-
130- class ProcessPoolForkMixin (ProcessPoolMixin ):
131124 ctx = "fork"
132125
133126 def setUp (self ):
@@ -136,11 +129,13 @@ def setUp(self):
136129 super ().setUp ()
137130
138131
139- class ProcessPoolSpawnMixin (ProcessPoolMixin ):
132+ class ProcessPoolSpawnMixin (ExecutorMixin ):
133+ executor_type = futures .ProcessPoolExecutor
140134 ctx = "spawn"
141135
142136
143- class ProcessPoolForkserverMixin (ProcessPoolMixin ):
137+ class ProcessPoolForkserverMixin (ExecutorMixin ):
138+ executor_type = futures .ProcessPoolExecutor
144139 ctx = "forkserver"
145140
146141 def setUp (self ):
@@ -232,7 +227,7 @@ def test_thread_names_default(self):
232227 t .join ()
233228
234229
235- class ProcessPoolShutdownTest (ProcessPoolMixin , ExecutorShutdownTest , BaseTestCase ):
230+ class ProcessPoolShutdownTest (ExecutorShutdownTest ):
236231 def _prime_executor (self ):
237232 pass
238233
@@ -519,7 +514,6 @@ class ThreadPoolAsCompletedTests(ThreadPoolMixin, AsCompletedTests, BaseTestCase
519514 pass
520515
521516
522-
523517class ProcessPoolForkAsCompletedTests (ProcessPoolForkMixin , AsCompletedTests ,
524518 BaseTestCase ):
525519 pass
0 commit comments