@@ -66,7 +66,7 @@ def make_dummy_object(_):
66
66
return MyObject ()
67
67
68
68
69
- class BaseTestCase (BaseTestCase ):
69
+ class BaseTestCase (unittest . TestCase ):
70
70
def setUp (self ):
71
71
self ._thread_key = test .support .threading_setup ()
72
72
@@ -83,7 +83,13 @@ def setUp(self):
83
83
84
84
self .t1 = time .time ()
85
85
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 )
87
93
except NotImplementedError as e :
88
94
self .skipTest (str (e ))
89
95
self ._prime_executor ()
@@ -113,21 +119,8 @@ class ThreadPoolMixin(ExecutorMixin):
113
119
executor_type = futures .ThreadPoolExecutor
114
120
115
121
116
- class ProcessPoolMixin (ExecutorMixin ):
122
+ class ProcessPoolForkMixin (ExecutorMixin ):
117
123
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 ):
131
124
ctx = "fork"
132
125
133
126
def setUp (self ):
@@ -136,11 +129,13 @@ def setUp(self):
136
129
super ().setUp ()
137
130
138
131
139
- class ProcessPoolSpawnMixin (ProcessPoolMixin ):
132
+ class ProcessPoolSpawnMixin (ExecutorMixin ):
133
+ executor_type = futures .ProcessPoolExecutor
140
134
ctx = "spawn"
141
135
142
136
143
- class ProcessPoolForkserverMixin (ProcessPoolMixin ):
137
+ class ProcessPoolForkserverMixin (ExecutorMixin ):
138
+ executor_type = futures .ProcessPoolExecutor
144
139
ctx = "forkserver"
145
140
146
141
def setUp (self ):
@@ -232,7 +227,7 @@ def test_thread_names_default(self):
232
227
t .join ()
233
228
234
229
235
- class ProcessPoolShutdownTest (ProcessPoolMixin , ExecutorShutdownTest , BaseTestCase ):
230
+ class ProcessPoolShutdownTest (ExecutorShutdownTest ):
236
231
def _prime_executor (self ):
237
232
pass
238
233
@@ -519,7 +514,6 @@ class ThreadPoolAsCompletedTests(ThreadPoolMixin, AsCompletedTests, BaseTestCase
519
514
pass
520
515
521
516
522
-
523
517
class ProcessPoolForkAsCompletedTests (ProcessPoolForkMixin , AsCompletedTests ,
524
518
BaseTestCase ):
525
519
pass
0 commit comments