@@ -90,25 +90,29 @@ def test_build_arch(
90
90
android_ndk = self .ctx ._ndk_dir
91
91
)
92
92
mock_glob .return_value = ["llvm" ]
93
+
94
+ # Since the following mocks are dynamic,
95
+ # we mock/test it inside a Context Manager
93
96
with mock .patch (
94
97
f"pythonforandroid.recipes.{ self .recipe_name } .sh.Command"
95
98
) as mock_sh_command , mock .patch (
96
99
f"pythonforandroid.recipes.{ self .recipe_name } .sh.make"
97
100
) as mock_make :
98
101
self .recipe .build_arch (self .arch )
99
102
100
- # make sure that the mocked methods are actually called
101
- mock_glob .assert_called ()
102
- mock_ensure_dir .assert_called ()
103
- mock_current_directory .assert_called ()
104
- mock_find_executable .assert_called ()
105
103
for command in self .sh_command_calls :
106
104
self .assertIn (
107
105
mock .call (command ),
108
106
mock_sh_command .mock_calls ,
109
107
)
110
108
mock_make .assert_called ()
111
109
110
+ # make sure that the mocked methods are actually called
111
+ mock_glob .assert_called ()
112
+ mock_ensure_dir .assert_called ()
113
+ mock_current_directory .assert_called ()
114
+ mock_find_executable .assert_called ()
115
+
112
116
113
117
class BaseTestForCmakeRecipe (BaseTestForMakeRecipe ):
114
118
"""
@@ -135,17 +139,21 @@ def test_build_arch(
135
139
android_ndk = self .ctx ._ndk_dir
136
140
)
137
141
mock_glob .return_value = ["llvm" ]
142
+
143
+ # Since the following mocks are dynamic,
144
+ # we mock/test it inside a Context Manager
138
145
with mock .patch (
139
146
f"pythonforandroid.recipes.{ self .recipe_name } .sh.make"
140
147
) as mock_make , mock .patch (
141
148
f"pythonforandroid.recipes.{ self .recipe_name } .sh.cmake"
142
149
) as mock_cmake :
143
150
self .recipe .build_arch (self .arch )
144
151
145
- # make sure that the mocked methods are actually called
146
- mock_glob .assert_called ()
147
- mock_ensure_dir .assert_called ()
148
- mock_current_directory .assert_called ()
149
- mock_find_executable .assert_called ()
150
152
mock_cmake .assert_called ()
151
153
mock_make .assert_called ()
154
+
155
+ # make sure that the mocked methods are actually called
156
+ mock_glob .assert_called ()
157
+ mock_ensure_dir .assert_called ()
158
+ mock_current_directory .assert_called ()
159
+ mock_find_executable .assert_called ()
0 commit comments