From 9ef3f9f55caa4cdd4853f33c603f82cd73125777 Mon Sep 17 00:00:00 2001 From: Andre Miras Date: Thu, 29 Feb 2024 15:06:51 +0100 Subject: [PATCH] :white_check_mark: improve sh mocking reliability Make sure the mocking also works on setup without cmake or make. Build dependencies should not be required to run uni tests. The error was: ``` AttributeError: does not have the attribute 'cmake' ``` --- tests/recipes/recipe_lib_test.py | 6 +++--- tests/recipes/test_openal.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/recipes/recipe_lib_test.py b/tests/recipes/recipe_lib_test.py index 1f57fe23c1..34aec36dd2 100644 --- a/tests/recipes/recipe_lib_test.py +++ b/tests/recipes/recipe_lib_test.py @@ -88,7 +88,7 @@ def test_build_arch( with mock.patch( f"pythonforandroid.recipes.{self.recipe_name}.sh.Command" ) as mock_sh_command, mock.patch( - f"pythonforandroid.recipes.{self.recipe_name}.sh.make" + f"pythonforandroid.recipes.{self.recipe_name}.sh.make", create=True ) as mock_make: self.recipe.build_arch(self.arch) @@ -130,9 +130,9 @@ def test_build_arch( # Since the following mocks are dynamic, # we mock it inside a Context Manager with mock.patch( - f"pythonforandroid.recipes.{self.recipe_name}.sh.make" + f"pythonforandroid.recipes.{self.recipe_name}.sh.make", create=True ) as mock_make, mock.patch( - f"pythonforandroid.recipes.{self.recipe_name}.sh.cmake" + f"pythonforandroid.recipes.{self.recipe_name}.sh.cmake", create=True ) as mock_cmake: self.recipe.build_arch(self.arch) diff --git a/tests/recipes/test_openal.py b/tests/recipes/test_openal.py index a03d5cd271..fec7eeaa0e 100644 --- a/tests/recipes/test_openal.py +++ b/tests/recipes/test_openal.py @@ -9,8 +9,8 @@ class TestOpenalRecipe(BaseTestForCmakeRecipe, unittest.TestCase): """ recipe_name = "openal" - @mock.patch("pythonforandroid.recipes.openal.sh.cmake") - @mock.patch("pythonforandroid.recipes.openal.sh.make") + @mock.patch("pythonforandroid.recipes.openal.sh.cmake", create=True) + @mock.patch("pythonforandroid.recipes.openal.sh.make", create=True) @mock.patch("pythonforandroid.recipes.openal.sh.cp") @mock.patch("pythonforandroid.util.chdir") @mock.patch("pythonforandroid.build.ensure_dir")