diff --git a/src/briefcase/integrations/java.py b/src/briefcase/integrations/java.py index 4f041349e..ec73e3e3a 100644 --- a/src/briefcase/integrations/java.py +++ b/src/briefcase/integrations/java.py @@ -262,10 +262,9 @@ def install(self): with self.tools.input.wait_bar("Installing OpenJDK..."): try: - # TODO: Py3.6 compatibility; os.fsdecode not required in Py3.7 self.tools.shutil.unpack_archive( - os.fsdecode(jdk_zip_path), - extract_dir=os.fsdecode(self.tools.base_path), + str(jdk_zip_path), + extract_dir=str(self.tools.base_path), ) except (shutil.ReadError, EOFError) as e: raise BriefcaseCommandError( diff --git a/src/briefcase/integrations/wix.py b/src/briefcase/integrations/wix.py index f25603035..5df5433b7 100644 --- a/src/briefcase/integrations/wix.py +++ b/src/briefcase/integrations/wix.py @@ -1,6 +1,5 @@ from __future__ import annotations -import os import shutil from pathlib import Path @@ -138,10 +137,9 @@ def install(self): try: with self.tools.input.wait_bar("Installing WiX..."): - # TODO: Py3.6 compatibility; os.fsdecode not required in Py3.7 self.tools.shutil.unpack_archive( - os.fsdecode(wix_zip_path), - extract_dir=os.fsdecode(self.wix_home), + str(wix_zip_path), + extract_dir=str(self.wix_home), ) except (shutil.ReadError, EOFError) as e: raise BriefcaseCommandError( diff --git a/tests/integrations/android_sdk/AndroidSDK/test_verify_emulator_skin.py b/tests/integrations/android_sdk/AndroidSDK/test_verify_emulator_skin.py index 2981f4581..14bb070d4 100644 --- a/tests/integrations/android_sdk/AndroidSDK/test_verify_emulator_skin.py +++ b/tests/integrations/android_sdk/AndroidSDK/test_verify_emulator_skin.py @@ -20,8 +20,6 @@ def test_existing_skin(mock_tools, android_sdk): def test_new_skin(mock_tools, android_sdk): """If the skin doesn't exist, an attempt is made to download it.""" - # MagicMock below py3.8 doesn't have __fspath__ attribute. - # Remove if block when we drop py3.7 support. skin_tgz_path = MagicMock(spec_set=Path) skin_tgz_path.__fspath__.return_value = "/path/to/skin.tgz" mock_tools.download.file.return_value = skin_tgz_path @@ -50,8 +48,6 @@ def test_new_skin(mock_tools, android_sdk): def test_skin_download_failure(mock_tools, android_sdk, tmp_path): """If the skin download fails, an error is raised.""" - # MagicMock below py3.8 doesn't have __fspath__ attribute. - # Remove if block when we drop py3.7 support. skin_tgz_path = MagicMock(spec_set=Path) skin_tgz_path.__fspath__.return_value = "/path/to/skin.tgz" mock_tools.download.file.return_value = skin_tgz_path @@ -79,8 +75,6 @@ def test_skin_download_failure(mock_tools, android_sdk, tmp_path): def test_unpack_failure(mock_tools, android_sdk, tmp_path): """If the download is corrupted and unpacking fails, an error is raised.""" # Mock the result of the download of a skin - # Consider to remove if block when we drop py3.7 support, only keep statements from else. - # MagicMock below py3.8 doesn't have __fspath__ attribute. skin_tgz_path = MagicMock(spec_set=Path) skin_tgz_path.__fspath__.return_value = "/path/to/skin.tgz" mock_tools.download.file.return_value = skin_tgz_path diff --git a/tests/integrations/java/test_JDK__upgrade.py b/tests/integrations/java/test_JDK__upgrade.py index bc087a734..ab41abe20 100644 --- a/tests/integrations/java/test_JDK__upgrade.py +++ b/tests/integrations/java/test_JDK__upgrade.py @@ -1,4 +1,3 @@ -import os import shutil from unittest.mock import MagicMock @@ -60,10 +59,9 @@ def rmtree(path): mock_tools.shutil.rmtree.side_effect = rmtree # Mock the cached download path. - # Consider to remove if block when we drop py3.7 support, only keep statements from else. - # MagicMock below py3.8 doesn't have __fspath__ attribute. archive = MagicMock() archive.__fspath__.return_value = "/path/to/download.zip" + archive.__str__.return_value = "/path/to/download.zip" mock_tools.download.file.return_value = archive # Create a directory to make it look like Java was downloaded and unpacked. @@ -87,9 +85,8 @@ def rmtree(path): ) # The archive was unpacked. - # TODO: Py3.6 compatibility; os.fsdecode not required in Py3.7 mock_tools.shutil.unpack_archive.assert_called_with( - "/path/to/download.zip", extract_dir=os.fsdecode(tmp_path / "tools") + "/path/to/download.zip", extract_dir=str(tmp_path / "tools") ) # The original archive was deleted archive.unlink.assert_called_once_with() @@ -112,10 +109,9 @@ def rmtree(path): mock_tools.shutil.rmtree.side_effect = rmtree # Mock the cached download path. - # Consider to remove if block when we drop py3.7 support, only keep statements from else. - # MagicMock below py3.8 doesn't have __fspath__ attribute. archive = MagicMock() archive.__fspath__.return_value = "/path/to/download.zip" + archive.__str__.return_value = "/path/to/download.zip" mock_tools.download.file.return_value = archive # Create a directory to make it look like Java was downloaded and unpacked. @@ -139,10 +135,9 @@ def rmtree(path): ) # The archive was unpacked. - # TODO: Py3.6 compatibility; os.fsdecode not required in Py3.7 mock_tools.shutil.unpack_archive.assert_called_with( "/path/to/download.zip", - extract_dir=os.fsdecode(tmp_path / "tools"), + extract_dir=str(tmp_path / "tools"), ) # The original archive was deleted archive.unlink.assert_called_once_with() @@ -198,10 +193,9 @@ def rmtree(path): mock_tools.shutil.rmtree.side_effect = rmtree # Mock the cached download path - # Consider to remove if block when we drop py3.7 support, only keep statements from else. - # MagicMock below py3.8 doesn't have __fspath__ attribute. archive = MagicMock() archive.__fspath__.return_value = "/path/to/download.zip" + archive.__str__.return_value = "/path/to/download.zip" mock_tools.download.file.return_value = archive # Mock an unpack failure due to an invalid archive @@ -226,10 +220,9 @@ def rmtree(path): ) # The archive was unpacked. - # TODO: Py3.6 compatibility; os.fsdecode not required in Py3.7 mock_tools.shutil.unpack_archive.assert_called_with( "/path/to/download.zip", - extract_dir=os.fsdecode(tmp_path / "tools"), + extract_dir=str(tmp_path / "tools"), ) # The original archive was not deleted assert archive.unlink.call_count == 0 diff --git a/tests/integrations/java/test_JDK__verify.py b/tests/integrations/java/test_JDK__verify.py index 732057be6..c5b7a4d38 100644 --- a/tests/integrations/java/test_JDK__verify.py +++ b/tests/integrations/java/test_JDK__verify.py @@ -451,10 +451,9 @@ def test_successful_jdk_download( mock_tools.os.environ = {"JAVA_HOME": "/does/not/exist"} # Mock the cached download path - # Consider to remove if block when we drop py3.7 support, only keep statements from else. - # MagicMock below py3.8 doesn't have __fspath__ attribute. archive = mock.MagicMock() archive.__fspath__.return_value = "/path/to/download.zip" + archive.__str__.return_value = "/path/to/download.zip" mock_tools.download.file.return_value = archive # Create a directory to make it look like Java was downloaded and unpacked. @@ -477,9 +476,8 @@ def test_successful_jdk_download( role="Java 17 JDK", ) # The archive was unpacked - # TODO: Py3.6 compatibility; os.fsdecode not required in Py3.7 mock_tools.shutil.unpack_archive.assert_called_with( - "/path/to/download.zip", extract_dir=os.fsdecode(tmp_path / "tools") + "/path/to/download.zip", extract_dir=str(tmp_path / "tools") ) # The original archive was deleted archive.unlink.assert_called_once_with() @@ -529,10 +527,9 @@ def test_invalid_jdk_archive(mock_tools, tmp_path): mock_tools.host_arch = "x86_64" # Mock the cached download path - # Consider to remove if block when we drop py3.7 support, only keep statements from else. - # MagicMock below py3.8 doesn't have __fspath__ attribute. archive = mock.MagicMock() archive.__fspath__.return_value = "/path/to/download.zip" + archive.__str__.return_value = "/path/to/download.zip" mock_tools.download.file.return_value = archive # Mock an unpack failure due to an invalid archive @@ -549,10 +546,9 @@ def test_invalid_jdk_archive(mock_tools, tmp_path): role="Java 17 JDK", ) # An attempt was made to unpack the archive. - # TODO: Py3.6 compatibility; os.fsdecode not required in Py3.7 mock_tools.shutil.unpack_archive.assert_called_with( "/path/to/download.zip", - extract_dir=os.fsdecode(tmp_path / "tools"), + extract_dir=str(tmp_path / "tools"), ) # The original archive was not deleted assert archive.unlink.call_count == 0 diff --git a/tests/integrations/wix/test_WiX__upgrade.py b/tests/integrations/wix/test_WiX__upgrade.py index 988b3ec6f..d440f3c17 100644 --- a/tests/integrations/wix/test_WiX__upgrade.py +++ b/tests/integrations/wix/test_WiX__upgrade.py @@ -51,10 +51,9 @@ def test_existing_wix_install(mock_tools, tmp_path): wix_path = tmp_path / "tools" / "wix" wix_zip_path = os.fsdecode(tmp_path / "tools" / "wix.zip") - # Consider to remove if block when we drop py3.7 support, only keep statements from else. - # MagicMock below py3.8 doesn't have __fspath__ attribute. wix_zip = MagicMock() wix_zip.__fspath__.return_value = wix_zip_path + wix_zip.__str__.return_value = wix_zip_path mock_tools.download.file.return_value = wix_zip @@ -75,9 +74,8 @@ def test_existing_wix_install(mock_tools, tmp_path): ) # The download was unpacked - # TODO: Py3.6 compatibility; os.fsdecode not required in Py3.7 mock_tools.shutil.unpack_archive.assert_called_with( - os.fsdecode(wix_zip_path), extract_dir=os.fsdecode(wix_path) + str(wix_zip_path), extract_dir=str(wix_path) ) # The zip file was removed @@ -125,10 +123,9 @@ def test_unpack_fail(mock_tools, tmp_path): # Mock the download wix_zip_path = os.fsdecode(tmp_path / "tools" / "wix.zip") - # Consider to remove if block when we drop py3.7 support, only keep statements from else. - # MagicMock below py3.8 doesn't have __fspath__ attribute. wix_zip = MagicMock() wix_zip.__fspath__.return_value = wix_zip_path + wix_zip.__str__.return_value = wix_zip_path mock_tools.download.file.return_value = wix_zip @@ -151,9 +148,8 @@ def test_unpack_fail(mock_tools, tmp_path): ) # The download was unpacked. - # TODO: Py3.6 compatibility; os.fsdecode not required in Py3.7 mock_tools.shutil.unpack_archive.assert_called_with( - os.fsdecode(wix_zip_path), extract_dir=os.fsdecode(wix_path) + str(wix_zip_path), extract_dir=str(wix_path) ) # The zip file was not removed diff --git a/tests/integrations/wix/test_WiX__verify.py b/tests/integrations/wix/test_WiX__verify.py index b041426ea..42f64aea1 100644 --- a/tests/integrations/wix/test_WiX__verify.py +++ b/tests/integrations/wix/test_WiX__verify.py @@ -104,10 +104,9 @@ def test_download_wix(mock_tools, tmp_path): wix_path = tmp_path / "tools" / "wix" wix_zip_path = os.fsdecode(tmp_path / "tools" / "wix.zip") - # Consider to remove if block when we drop py3.7 support, only keep statements from else. - # MagicMock below py3.8 doesn't have __fspath__ attribute. wix_zip = MagicMock() wix_zip.__fspath__.return_value = wix_zip_path + wix_zip.__str__.return_value = wix_zip_path mock_tools.download.file.return_value = wix_zip @@ -125,9 +124,8 @@ def test_download_wix(mock_tools, tmp_path): ) # The download was unpacked. - # TODO: Py3.6 compatibility; os.fsdecode not required in Py3.7 mock_tools.shutil.unpack_archive.assert_called_with( - os.fsdecode(wix_zip_path), extract_dir=os.fsdecode(wix_path) + str(wix_zip_path), extract_dir=str(wix_path) ) # The zip file was removed @@ -191,10 +189,9 @@ def test_unpack_fail(mock_tools, tmp_path): wix_path = tmp_path / "tools" / "wix" wix_zip_path = os.fsdecode(tmp_path / "tools" / "wix.zip") - # Consider to remove if block when we drop py3.7 support, only keep statements from else. - # MagicMock below py3.8 doesn't have __fspath__ attribute. wix_zip = MagicMock() wix_zip.__fspath__.return_value = wix_zip_path + wix_zip.__str__.return_value = wix_zip_path mock_tools.download.file.return_value = wix_zip @@ -217,9 +214,8 @@ def test_unpack_fail(mock_tools, tmp_path): ) # The download was unpacked. - # TODO: Py3.6 compatibility; os.fsdecode not required in Py3.7 mock_tools.shutil.unpack_archive.assert_called_with( - os.fsdecode(wix_zip_path), extract_dir=os.fsdecode(wix_path) + str(wix_zip_path), extract_dir=str(wix_path) ) # The zip file was not removed