diff --git a/tests/targets/test_android.py b/tests/targets/test_android.py index 81f76ee09..0b020edb2 100644 --- a/tests/targets/test_android.py +++ b/tests/targets/test_android.py @@ -11,7 +11,7 @@ init_buildozer, patch_buildozer, patch_buildops_checkbin, - patch_buildozer_cmd, + patch_buildops_cmd, patch_buildops_file_exists, ) @@ -131,14 +131,14 @@ def test_sdkmanager(self): """Tests the _sdkmanager() method.""" target_android = init_target(self.temp_dir) kwargs = {} - with patch_buildozer_cmd() as m_cmd, patch_buildozer_cmd_expect() as m_cmd_expect, patch_os_isfile() as m_isfile: + with patch_buildops_cmd() as m_cmd, patch_buildozer_cmd_expect() as m_cmd_expect, patch_os_isfile() as m_isfile: m_isfile.return_value = True assert m_cmd.return_value == target_android._sdkmanager(**kwargs) assert m_cmd.call_count == 1 assert m_cmd_expect.call_count == 0 assert m_isfile.call_count == 1 kwargs = {"return_child": True} - with patch_buildozer_cmd() as m_cmd, patch_buildozer_cmd_expect() as m_cmd_expect, patch_os_isfile() as m_isfile: + with patch_buildops_cmd() as m_cmd, patch_buildozer_cmd_expect() as m_cmd_expect, patch_os_isfile() as m_isfile: m_isfile.return_value = True assert m_cmd_expect.return_value == target_android._sdkmanager( **kwargs @@ -429,13 +429,14 @@ def test_install_platform_p4a_clone_url(self): 'p4a.fork': 'myfork', }) - with patch_buildozer_cmd() as m_cmd, mock.patch('buildozer.targets.android.open') as m_open: + with patch_buildops_cmd() as m_cmd, mock.patch('buildozer.targets.android.open') as m_open: m_open.return_value = StringIO('install_reqs = []') # to stub setup.py parsing target_android._install_p4a() assert mock.call( ["git", "clone", "-b", "master", "--single-branch", "https://custom-p4a-url/p4a.git", "python-for-android"], - cwd=mock.ANY) in m_cmd.call_args_list + cwd=mock.ANY, + env=mock.ANY) in m_cmd.call_args_list def test_install_platform_p4a_clone_fork(self): """The `p4a.fork` config should be used for cloning p4a.""" @@ -443,25 +444,27 @@ def test_install_platform_p4a_clone_fork(self): 'p4a.fork': 'fork' }) - with patch_buildozer_cmd() as m_cmd, mock.patch('buildozer.targets.android.open') as m_open: + with patch_buildops_cmd() as m_cmd, mock.patch('buildozer.targets.android.open') as m_open: m_open.return_value = StringIO('install_reqs = []') # to stub setup.py parsing target_android._install_p4a() assert mock.call( ["git", "clone", "-b", "master", "--single-branch", "https://github.com/fork/python-for-android.git", "python-for-android"], - cwd=mock.ANY) in m_cmd.call_args_list + cwd=mock.ANY, + env=mock.ANY) in m_cmd.call_args_list def test_install_platform_p4a_clone_default(self): """The default URL should be used for cloning p4a if no config options `p4a.url` and `p4a.fork` are set.""" target_android = init_target(self.temp_dir) - with patch_buildozer_cmd() as m_cmd, mock.patch('buildozer.targets.android.open') as m_open: + with patch_buildops_cmd() as m_cmd, mock.patch('buildozer.targets.android.open') as m_open: m_open.return_value = StringIO('install_reqs = []') # to stub setup.py parsing target_android._install_p4a() assert mock.call( ["git", "clone", "-b", "master", "--single-branch", "https://github.com/kivy/python-for-android.git", "python-for-android"], - cwd=mock.ANY) in m_cmd.call_args_list + cwd=mock.ANY, + env=mock.ANY) in m_cmd.call_args_list def test_orientation(self): target_android = init_target(self.temp_dir, { diff --git a/tests/targets/test_ios.py b/tests/targets/test_ios.py index 071b72efe..ce95ac58a 100644 --- a/tests/targets/test_ios.py +++ b/tests/targets/test_ios.py @@ -10,7 +10,7 @@ from tests.targets.utils import ( init_buildozer, patch_buildops_checkbin, - patch_buildozer_cmd, + patch_buildops_cmd, patch_buildops_file_exists, patch_logger_error, ) @@ -112,7 +112,7 @@ def test_install_platform(self): target = init_target(self.temp_dir) assert target.ios_dir is None assert target.ios_deploy_dir is None - with patch_buildozer_cmd() as m_cmd: + with patch_buildops_cmd() as m_cmd: target.install_platform() assert m_cmd.call_args_list == [ mock.call( @@ -124,6 +124,7 @@ def test_install_platform(self): "https://github.com/kivy/kivy-ios", ], cwd=mock.ANY, + env=mock.ANY, ), mock.call( [ @@ -134,6 +135,7 @@ def test_install_platform(self): "https://github.com/phonegap/ios-deploy", ], cwd=mock.ANY, + env=mock.ANY, ), ] assert target.ios_dir.endswith(".buildozer/ios/platform/kivy-ios") @@ -176,7 +178,7 @@ def test_unlock_keychain_wrong_password(self): target = init_target(self.temp_dir) # fmt: off with mock.patch("buildozer.targets.ios.getpass") as m_getpass, \ - patch_buildozer_cmd() as m_cmd, \ + patch_buildops_cmd() as m_cmd, \ pytest.raises(BuildozerCommandException): m_getpass.return_value = "password" # the `security unlock-keychain` command returned an error @@ -199,7 +201,7 @@ def test_build_package_no_signature(self): patch_logger_error() as m_error, \ mock.patch("buildozer.targets.ios.TargetIos.load_plist_from_file") as m_load_plist_from_file, \ mock.patch("buildozer.targets.ios.TargetIos.dump_plist_to_file") as m_dump_plist_to_file, \ - patch_buildozer_cmd() as m_cmd: + patch_buildops_cmd() as m_cmd: m_load_plist_from_file.return_value = {} target.build_package() # fmt: on @@ -235,6 +237,7 @@ def test_build_package_no_signature(self): "clean", "build"], cwd="/ios/dir/myapp-ios", + env=MOCK.ANY, ), mock.call([ "xcodebuild", diff --git a/tests/targets/utils.py b/tests/targets/utils.py index e98940780..f328c36bc 100644 --- a/tests/targets/utils.py +++ b/tests/targets/utils.py @@ -10,8 +10,8 @@ def patch_buildozer(method): return mock.patch("buildozer.Buildozer.{method}".format(method=method)) -def patch_buildozer_cmd(): - return patch_buildozer("cmd") +def patch_buildops_cmd(): + return mock.patch("buildozer.buildops.cmd") def patch_buildops_checkbin(): diff --git a/tests/test_buildozer.py b/tests/test_buildozer.py index 3e7625978..6f1a8a451 100644 --- a/tests/test_buildozer.py +++ b/tests/test_buildozer.py @@ -129,7 +129,8 @@ def test_android_ant_path(self): mock.patch('buildozer.buildops.file_extract') as m_file_extract, \ mock.patch('os.makedirs'): ant_path = target._install_apache_ant() - assert m_file_extract.call_args_list == [mock.call(mock.ANY, cwd='/my/ant/path')] + assert m_file_extract.call_args_list == [ + mock.call(mock.ANY, cwd='/my/ant/path', env=mock.ANY)] assert ant_path == my_ant_path assert download.call_args_list == [ mock.call("https://archive.apache.org/dist/ant/binaries/", mock.ANY, cwd=my_ant_path)]