@@ -353,34 +353,30 @@ def bootstrap_name(self):
353353 name of the bootstrap to test"""
354354 raise NotImplementedError ("Not implemented in GenericBootstrapTest" )
355355
356+ @mock .patch ("pythonforandroid.bootstraps.qt.shprint" )
357+ @mock .patch ("pythonforandroid.bootstraps.qt.rmdir" )
356358 @mock .patch ("pythonforandroid.bootstraps.qt.open" , create = True )
357- @mock .patch ("pythonforandroid.bootstraps.service_only.open" , create = True )
358- @mock .patch ("pythonforandroid.bootstraps.webview.open" , create = True )
359- @mock .patch ("pythonforandroid.bootstraps._sdl_common.open" , create = True )
359+ @mock .patch ("pythonforandroid.bootstrap.open" , create = True )
360360 @mock .patch ("pythonforandroid.distribution.open" , create = True )
361361 @mock .patch ("pythonforandroid.bootstrap.Bootstrap.strip_libraries" )
362362 @mock .patch ("pythonforandroid.util.exists" )
363363 @mock .patch ("pythonforandroid.util.chdir" )
364364 @mock .patch ("pythonforandroid.bootstrap.listdir" )
365- @mock .patch ("pythonforandroid.bootstraps._sdl_common.rmdir" )
366- @mock .patch ("pythonforandroid.bootstraps.service_only.rmdir" )
367- @mock .patch ("pythonforandroid.bootstraps.webview.rmdir" )
368- @mock .patch ("pythonforandroid.bootstrap.sh.cp" )
365+ @mock .patch ("pythonforandroid.bootstrap.rmdir" )
366+ @mock .patch ("pythonforandroid.bootstrap.shprint" )
369367 def test_assemble_distribution (
370368 self ,
371- mock_sh_cp ,
372- mock_rmdir1 ,
373- mock_rmdir2 ,
374- mock_rmdir3 ,
369+ mock_shprint ,
370+ mock_rmdir ,
375371 mock_listdir ,
376372 mock_chdir ,
377373 mock_ensure_dir ,
378374 mock_strip_libraries ,
379375 mock_open_dist_files ,
380- mock_open_sdl_files ,
381- mock_open_webview_files ,
382- mock_open_service_only_files ,
383- mock_open_qt_files
376+ mock_open_bootstrap_files ,
377+ mock_open_qt_files ,
378+ mock_qt_rmdir ,
379+ mock_qt_shprint
384380 ):
385381 """
386382 A test for any overwritten method of
@@ -417,13 +413,11 @@ def test_assemble_distribution(
417413 bs .assemble_distribution ()
418414
419415 mock_open_dist_files .assert_called_once_with ("dist_info.json" , "w" )
420- mock_open_bootstraps = {
421- "sdl2" : mock_open_sdl_files ,
422- "sdl3" : mock_open_sdl_files ,
423- "webview" : mock_open_webview_files ,
424- "service_only" : mock_open_service_only_files ,
425- "qt" : mock_open_qt_files
426- }
416+ # Qt bootstrap has its own assemble_distribution, others use base class
417+ if self .bootstrap_name == "qt" :
418+ mock_open_bs = mock_open_qt_files
419+ else :
420+ mock_open_bs = mock_open_bootstrap_files
427421 expected_open_calls = {
428422 "sdl2" : [
429423 mock .call ("local.properties" , "w" ),
@@ -433,11 +427,16 @@ def test_assemble_distribution(
433427 mock .call ("local.properties" , "w" ),
434428 mock .call ("blacklist.txt" , "a" ),
435429 ],
436- "webview" : [mock .call ("local.properties" , "w" )],
437- "service_only" : [mock .call ("local.properties" , "w" )],
430+ "webview" : [
431+ mock .call ("local.properties" , "w" ),
432+ mock .call ("blacklist.txt" , "a" ),
433+ ],
434+ "service_only" : [
435+ mock .call ("local.properties" , "w" ),
436+ mock .call ("blacklist.txt" , "a" ),
437+ ],
438438 "qt" : [mock .call ("local.properties" , "w" )]
439439 }
440- mock_open_bs = mock_open_bootstraps [self .bootstrap_name ]
441440 # test that the expected calls has been called
442441 for expected_call in expected_open_calls [self .bootstrap_name ]:
443442 self .assertIn (expected_call , mock_open_bs .call_args_list )
@@ -446,7 +445,7 @@ def test_assemble_distribution(
446445 mock .call ().__enter__ ().write ("sdk.dir=/opt/android/android-sdk" ),
447446 mock_open_bs .mock_calls ,
448447 )
449- if self .bootstrap_name in ["sdl2" , "sdl3" ]:
448+ if self .bootstrap_name in ["sdl2" , "sdl3" , "webview" , "service_only" ]:
450449 self .assertIn (
451450 mock .call ()
452451 .__enter__ ()
@@ -455,7 +454,7 @@ def test_assemble_distribution(
455454 )
456455
457456 # check that the other mocks we made are actually called
458- mock_sh_cp .assert_called ()
457+ mock_shprint .assert_called ()
459458 mock_chdir .assert_called ()
460459 mock_listdir .assert_called ()
461460 mock_strip_libraries .assert_called ()
0 commit comments