Skip to content

Commit 9024f9d

Browse files
committed
test(core): Patch os.name in the Windows _HostingContainer.down test
test_hosting_container_down_windows was one of the duplicate test definitions this branch un-shadowed, so it ran for the first time in CI and failed with ``ValueError: Invalid PID``. It patched ``platform.system`` to return "Windows", but ``_HostingContainer.down`` branches on ``os.name != "nt"``, so on the Linux runner it still called ``kill_child_processes`` with a Mock pid. Patch ``os.name`` in the module under test instead, which exercises the Windows branch the test describes.
1 parent f2ef154 commit 9024f9d

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

‎sagemaker-core/tests/unit/local/test_image.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -516,10 +516,9 @@ def test_hosting_container_down_unix(self, mock_platform, mock_kill):
516516
mock_kill.assert_called_once_with(12345)
517517
mock_process.terminate.assert_called_once()
518518

519-
@patch("platform.system")
520-
def test_hosting_container_down_windows(self, mock_platform):
519+
@patch("sagemaker.core.local.image.os.name", "nt")
520+
def test_hosting_container_down_windows(self):
521521
"""Test _HostingContainer down method on Windows"""
522-
mock_platform.return_value = "Windows"
523522
mock_process = Mock()
524523

525524
container = _HostingContainer(["docker", "compose", "up"])

0 commit comments

Comments
 (0)