Skip to content

Commit

Permalink
🐛 🔧 (#1342) fix Zappa.create_handler_venv win32 case where stderror_r…
Browse files Browse the repository at this point in the history
…esult is None
  • Loading branch information
storkwrangler committed Sep 30, 2024
1 parent b00312d commit cc3b0d8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
26 changes: 26 additions & 0 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2634,6 +2634,32 @@ def test_wsgi_query_string_with_encodechars(self):
expected = "query=Jane%26John&otherquery=B&test=hello%2Bm.te%26how%26are%26you"
self.assertEqual(request["QUERY_STRING"], expected)

@mock.patch()
@mock.patch(subprocess.Popen)
def test_create_handler_venv_win32_none_stderror_result(self, popen_mock):

class PopenMock:
return_code = 999

@classmethod
def communicate(cls):
return "valid_stdout", None # On win32, stderr can be None


popen_mock.return_value = PopenMock

boto_mock = mock.MagicMock()
zappa_core = Zappa(
boto_session=boto_mock,
profile_name="test",
aws_region="test",
load_credentials=True,
)

with self.assertRaises(EnvironmentError):
zappa_core.create_handler_venv()



if __name__ == "__main__":
unittest.main()
4 changes: 2 additions & 2 deletions zappa/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,9 @@ def create_handler_venv(self, use_zappa_release: Optional[str] = None):

if pip_return_code:
logger.info("command: %s", " ".join(command))
if stdout_result.strip():
if stdout_result and stdout_result.strip():
logger.info("stdout: %s", stdout_result.strip())
if stderror_result.strip():
if stderror_result and stderror_result.strip():
logger.error("stderr: %s", stderror_result)
raise EnvironmentError("Pypi lookup failed")

Expand Down

0 comments on commit cc3b0d8

Please sign in to comment.