Skip to content

Commit 9ef3f9f

Browse files
committed
✅ 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: <module 'sh' from 'venv/lib/python3.11/site-packages/sh.py'> does not have the attribute 'cmake' ```
1 parent 0047b4f commit 9ef3f9f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Diff for: tests/recipes/recipe_lib_test.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def test_build_arch(
8888
with mock.patch(
8989
f"pythonforandroid.recipes.{self.recipe_name}.sh.Command"
9090
) as mock_sh_command, mock.patch(
91-
f"pythonforandroid.recipes.{self.recipe_name}.sh.make"
91+
f"pythonforandroid.recipes.{self.recipe_name}.sh.make", create=True
9292
) as mock_make:
9393
self.recipe.build_arch(self.arch)
9494

@@ -130,9 +130,9 @@ def test_build_arch(
130130
# Since the following mocks are dynamic,
131131
# we mock it inside a Context Manager
132132
with mock.patch(
133-
f"pythonforandroid.recipes.{self.recipe_name}.sh.make"
133+
f"pythonforandroid.recipes.{self.recipe_name}.sh.make", create=True
134134
) as mock_make, mock.patch(
135-
f"pythonforandroid.recipes.{self.recipe_name}.sh.cmake"
135+
f"pythonforandroid.recipes.{self.recipe_name}.sh.cmake", create=True
136136
) as mock_cmake:
137137
self.recipe.build_arch(self.arch)
138138

Diff for: tests/recipes/test_openal.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ class TestOpenalRecipe(BaseTestForCmakeRecipe, unittest.TestCase):
99
"""
1010
recipe_name = "openal"
1111

12-
@mock.patch("pythonforandroid.recipes.openal.sh.cmake")
13-
@mock.patch("pythonforandroid.recipes.openal.sh.make")
12+
@mock.patch("pythonforandroid.recipes.openal.sh.cmake", create=True)
13+
@mock.patch("pythonforandroid.recipes.openal.sh.make", create=True)
1414
@mock.patch("pythonforandroid.recipes.openal.sh.cp")
1515
@mock.patch("pythonforandroid.util.chdir")
1616
@mock.patch("pythonforandroid.build.ensure_dir")

0 commit comments

Comments
 (0)