Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚑 Fix test_should_build #2193

Merged
merged 1 commit into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pythonforandroid/recipes/python3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

from multiprocessing import cpu_count
from os import environ
from os.path import dirname, exists, join, isfile
from os.path import dirname, exists, join
from pathlib import Path
from shutil import copy2

from pythonforandroid.logger import info, warning, shprint
Expand Down Expand Up @@ -165,7 +166,7 @@ def link_root(self, arch_name):
return join(self.get_build_dir(arch_name), 'android-build')

def should_build(self, arch):
return not isfile(join(self.link_root(arch.arch), self._libpython))
return not Path(self.link_root(arch.arch), self._libpython).is_file()

def prebuild_arch(self, arch):
super().prebuild_arch(arch)
Expand Down
14 changes: 7 additions & 7 deletions tests/recipes/test_python3.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ def test_property__libpython(self):
f'libpython{self.recipe.major_minor_version_string}m.so'
)

def test_should_build(self):
expected_include_dir = join(
self.recipe.get_build_dir(self.arch.arch), 'Include',
)
self.assertEqual(
expected_include_dir, self.recipe.include_root(self.arch.arch)
)
@mock.patch('pythonforandroid.recipes.python3.Path.is_file')
def test_should_build(self, mock_is_file):
# in case that python lib exists, we shouldn't trigger the build
self.assertFalse(self.recipe.should_build(self.arch))
# in case that python lib doesn't exist, we should trigger the build
mock_is_file.return_value = False
self.assertTrue(self.recipe.should_build(self.arch))

def test_include_root(self):
expected_include_dir = join(
Expand Down