(
self,
mock_shutil_which,
mock_makedirs,
mock_chdir)
| 77 | @mock.patch("pythonforandroid.util.makedirs") |
| 78 | @mock.patch("shutil.which") |
| 79 | def test_build_arch( |
| 80 | self, |
| 81 | mock_shutil_which, |
| 82 | mock_makedirs, |
| 83 | mock_chdir): |
| 84 | mock_shutil_which.return_value = self.expected_compiler |
| 85 | |
| 86 | # specific `build_arch` mocks |
| 87 | with mock.patch( |
| 88 | "builtins.open", |
| 89 | mock.mock_open(read_data="#define ZLIB_VERSION 1.1\nfoo") |
| 90 | ) as mock_open_zlib, mock.patch( |
| 91 | "pythonforandroid.recipes.python3.sh.Command" |
| 92 | ) as mock_sh_command, mock.patch( |
| 93 | "pythonforandroid.recipes.python3.sh.make" |
| 94 | ) as mock_make, mock.patch( |
| 95 | "pythonforandroid.recipes.python3.sh.cp" |
| 96 | ) as mock_cp: |
| 97 | self.recipe.build_arch(self.arch) |
| 98 | |
| 99 | # make sure that the mocked methods are actually called |
| 100 | recipe_build_dir = self.recipe.get_build_dir(self.arch.arch) |
| 101 | sh_command_calls = { |
| 102 | f"{recipe_build_dir}/config.guess", |
| 103 | f"{recipe_build_dir}/configure", |
| 104 | } |
| 105 | for command in sh_command_calls: |
| 106 | self.assertIn( |
| 107 | mock.call(command), |
| 108 | mock_sh_command.mock_calls, |
| 109 | ) |
| 110 | mock_open_zlib.assert_called() |
| 111 | self.assertEqual(mock_make.call_count, 2) |
| 112 | make_call, kw = mock_make.call_args_list[0] |
| 113 | self.assertIn( |
| 114 | f'INSTSONAME={self.recipe._libpython}', make_call |
| 115 | ) |
| 116 | mock_cp.assert_called_with( |
| 117 | "pyconfig.h", join(recipe_build_dir, 'Include'), |
| 118 | ) |
| 119 | mock_makedirs.assert_called() |
| 120 | mock_chdir.assert_called() |
| 121 | |
| 122 | def test_build_arch_wrong_ndk_api(self): |
| 123 | # we check ndk_api using recipe's ctx |
nothing calls this directly
no test coverage detected