@@ -3751,9 +3751,7 @@ def test_shared_memory_SharedMemoryManager_basics(self):
3751
3751
3752
3752
with shared_memory .SharedMemoryManager () as smm2 :
3753
3753
sl = smm2 .ShareableList ("howdy" )
3754
- unnecessary_lock = smm2 .Lock ()
3755
- with unnecessary_lock :
3756
- shm = smm2 .SharedMemory (size = 128 )
3754
+ shm = smm2 .SharedMemory (size = 128 )
3757
3755
held_name = sl .shm .name
3758
3756
if sys .platform != "win32" :
3759
3757
with self .assertRaises (FileNotFoundError ):
@@ -4944,9 +4942,29 @@ def is_alive(self):
4944
4942
any (process .is_alive () for process in forked_processes ))
4945
4943
4946
4944
4947
- class _MixinTestCommonManagerTypes (object ):
4945
+ class TestSyncManagerTypes (unittest .TestCase ):
4946
+ """Test all the types which can be shared between a parent and a
4947
+ child process by using a manager which acts as an intermediary
4948
+ between them.
4949
+
4950
+ In the following unit-tests the base type is created in the parent
4951
+ process, the @classmethod represents the worker process and the
4952
+ shared object is readable and editable between the two.
4953
+
4954
+ # The child.
4955
+ @classmethod
4956
+ def _test_list(cls, obj):
4957
+ assert obj[0] == 5
4958
+ assert obj.append(6)
4948
4959
4949
- manager_class = None
4960
+ # The parent.
4961
+ def test_list(self):
4962
+ o = self.manager.list()
4963
+ o.append(5)
4964
+ self.run_worker(self._test_list, o)
4965
+ assert o[1] == 6
4966
+ """
4967
+ manager_class = multiprocessing .managers .SyncManager
4950
4968
4951
4969
def setUp (self ):
4952
4970
self .manager = self .manager_class ()
@@ -5056,31 +5074,6 @@ def test_barrier(self):
5056
5074
o = self .manager .Barrier (5 )
5057
5075
self .run_worker (self ._test_barrier , o )
5058
5076
5059
-
5060
- class TestSyncManagerTypes (_MixinTestCommonManagerTypes , unittest .TestCase ):
5061
- """Test all the types which can be shared between a parent and a
5062
- child process by using a manager which acts as an intermediary
5063
- between them.
5064
-
5065
- In the following unit-tests the base type is created in the parent
5066
- process, the @classmethod represents the worker process and the
5067
- shared object is readable and editable between the two.
5068
-
5069
- # The child.
5070
- @classmethod
5071
- def _test_list(cls, obj):
5072
- assert obj[0] == 5
5073
- assert obj.append(6)
5074
-
5075
- # The parent.
5076
- def test_list(self):
5077
- o = self.manager.list()
5078
- o.append(5)
5079
- self.run_worker(self._test_list, o)
5080
- assert o[1] == 6
5081
- """
5082
- manager_class = multiprocessing .managers .SyncManager
5083
-
5084
5077
@classmethod
5085
5078
def _test_pool (cls , obj ):
5086
5079
# TODO: fix https://bugs.python.org/issue35919
@@ -5186,20 +5179,6 @@ def test_namespace(self):
5186
5179
self .run_worker (self ._test_namespace , o )
5187
5180
5188
5181
5189
- try :
5190
- import multiprocessing .shared_memory
5191
- except ImportError :
5192
- @unittest .skip ("SharedMemoryManager not available on this platform" )
5193
- class TestSharedMemoryManagerTypes (_MixinTestCommonManagerTypes ,
5194
- unittest .TestCase ):
5195
- pass
5196
- else :
5197
- class TestSharedMemoryManagerTypes (_MixinTestCommonManagerTypes ,
5198
- unittest .TestCase ):
5199
- """Same as above but by using SharedMemoryManager."""
5200
- manager_class = multiprocessing .shared_memory .SharedMemoryManager
5201
-
5202
-
5203
5182
class MiscTestCase (unittest .TestCase ):
5204
5183
def test__all__ (self ):
5205
5184
# Just make sure names in blacklist are excluded
0 commit comments