@@ -5173,6 +5173,23 @@ def test_invalid_handles(self):
51735173 multiprocessing .connection .Connection , - 1 )
51745174
51755175
5176+ #
5177+ # Regression tests for BaseProcess kwargs handling
5178+ #
5179+
5180+ class TestBaseProcessKwargs (unittest .TestCase ):
5181+ def test_default_kwargs_not_shared_between_instances (self ):
5182+ # Creating multiple Process instances without passing kwargs
5183+ # must create independent empty dicts (no shared state).
5184+ p1 = multiprocessing .Process (target = lambda : None )
5185+ p2 = multiprocessing .Process (target = lambda : None )
5186+ self .assertIsInstance (p1 ._kwargs , dict )
5187+ self .assertIsInstance (p2 ._kwargs , dict )
5188+ self .assertIsNot (p1 ._kwargs , p2 ._kwargs )
5189+ # Mutating one should not affect the other
5190+ p1 ._kwargs ['x' ] = 1
5191+ self .assertNotIn ('x' , p2 ._kwargs )
5192+
51765193
51775194@hashlib_helper .requires_hashdigest ('sha256' )
51785195class OtherTest (unittest .TestCase ):
@@ -6883,6 +6900,18 @@ def child():
68836900 self .assertEqual (q .get_nowait (), "done" )
68846901 close_queue (q )
68856902
6903+ def test_preload_main (self ):
6904+ # gh-126631: Check that __main__ can be pre-loaded
6905+ if multiprocessing .get_start_method () != "forkserver" :
6906+ self .skipTest ("forkserver specific test" )
6907+
6908+ name = os .path .join (os .path .dirname (__file__ ), 'mp_preload_main.py' )
6909+ _ , out , err = test .support .script_helper .assert_python_ok (name )
6910+ self .assertEqual (err , b'' )
6911+
6912+ # The trailing empty string comes from split() on output ending with \n
6913+ out = out .decode ().split ("\n " )
6914+ self .assertEqual (out , ['__main__' , '__mp_main__' , 'f' , 'f' , '' ])
68866915
68876916#
68886917# Mixins
0 commit comments