From bbc0f033e153c7ff1244273d78f935752573a104 Mon Sep 17 00:00:00 2001 From: Lucas <12496191+lucashuy@users.noreply.github.com> Date: Thu, 11 May 2023 14:16:40 -0700 Subject: [PATCH] fix: Clean up lingering test file (#5157) * Clean up lingering test file * Mock the call to open instead (this is easier) * make format and removed unused import --- tests/unit/local/lambdafn/test_remote_files.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/unit/local/lambdafn/test_remote_files.py b/tests/unit/local/lambdafn/test_remote_files.py index 1a5f8e7ddc..cebaf2d5c2 100644 --- a/tests/unit/local/lambdafn/test_remote_files.py +++ b/tests/unit/local/lambdafn/test_remote_files.py @@ -10,7 +10,10 @@ class TestUnzipFromUri(TestCase): @patch("samcli.local.lambdafn.remote_files.progressbar") @patch("samcli.local.lambdafn.remote_files.requests") @patch("samcli.local.lambdafn.remote_files.os") - def test_successfully_unzip_from_uri(self, os_patch, requests_patch, progressbar_patch, path_patch, unzip_patch): + @patch("samcli.local.lambdafn.remote_files.open") + def test_successfully_unzip_from_uri( + self, open_mock, os_patch, requests_patch, progressbar_patch, path_patch, unzip_patch + ): get_request_mock = Mock() get_request_mock.headers = {"Content-length": "200"} get_request_mock.iter_content.return_value = [b"data1"] @@ -40,8 +43,9 @@ def test_successfully_unzip_from_uri(self, os_patch, requests_patch, progressbar @patch("samcli.local.lambdafn.remote_files.progressbar") @patch("samcli.local.lambdafn.remote_files.requests") @patch("samcli.local.lambdafn.remote_files.os") + @patch("samcli.local.lambdafn.remote_files.open") def test_not_unlink_file_when_file_doesnt_exist( - self, os_patch, requests_patch, progressbar_patch, path_patch, unzip_patch + self, open_mock, os_patch, requests_patch, progressbar_patch, path_patch, unzip_patch ): get_request_mock = Mock() get_request_mock.headers = {"Content-length": "200"} @@ -72,8 +76,9 @@ def test_not_unlink_file_when_file_doesnt_exist( @patch("samcli.local.lambdafn.remote_files.progressbar") @patch("samcli.local.lambdafn.remote_files.requests") @patch("samcli.local.lambdafn.remote_files.os") + @patch("samcli.local.lambdafn.remote_files.open") def test_unzip_from_uri_reads_AWS_CA_BUNDLE_env_var( - self, os_patch, requests_patch, progressbar_patch, path_patch, unzip_patch + self, open_mock, os_patch, requests_patch, progressbar_patch, path_patch, unzip_patch ): get_request_mock = Mock() get_request_mock.headers = {"Content-length": "200"}