From 92da291bb4f3f7b18f91b2410caca499aac8ef86 Mon Sep 17 00:00:00 2001 From: scspaldi Date: Thu, 27 Jan 2022 17:06:47 -0800 Subject: [PATCH] Changed kill() to protected. Changed references from kill() to stop(). Signed-off-by: scspaldi --- .../Gem/PythonTests/automatedtesting_shared/base.py | 4 ++-- .../ly_test_tools/launchers/platforms/android/launcher.py | 2 +- Tools/LyTestTools/ly_test_tools/launchers/platforms/base.py | 6 +++--- .../ly_test_tools/launchers/platforms/linux/launcher.py | 2 +- .../ly_test_tools/launchers/platforms/mac/launcher.py | 2 +- .../ly_test_tools/launchers/platforms/win/launcher.py | 2 +- Tools/LyTestTools/ly_test_tools/o3de/editor_test.py | 4 ++-- Tools/LyTestTools/tests/unit/test_launcher_android.py | 6 ++++-- Tools/LyTestTools/tests/unit/test_launcher_base.py | 4 ++-- Tools/LyTestTools/tests/unit/test_launcher_linux.py | 4 ++-- Tools/LyTestTools/tests/unit/test_launcher_mac.py | 4 ++-- Tools/LyTestTools/tests/unit/test_launcher_win.py | 4 ++-- Tools/LyTestTools/tests/unit/test_o3de_editor_test.py | 2 +- 13 files changed, 24 insertions(+), 22 deletions(-) diff --git a/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/base.py b/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/base.py index 4db959b23e..e59282c97b 100755 --- a/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/base.py +++ b/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/base.py @@ -78,7 +78,7 @@ class TestAutomationBase: file_system.restore_backup(workspace.paths.editor_log(), workspace.paths.project_log()) except FileNotFoundError as e: self.logger.debug(f"File restoration failed, editor log could not be found.\nError: {e}") - editor.kill() + editor.stop() request.addfinalizer(teardown) @@ -113,7 +113,7 @@ class TestAutomationBase: editor.wait(TestAutomationBase.MAX_TIMEOUT) except WaitTimeoutError: errors.append(TestRunError("TIMEOUT", f"Editor did not close after {TestAutomationBase.MAX_TIMEOUT} seconds, verify the test is ending and the application didn't freeze")) - editor.kill() + editor.stop() output = editor.get_output() self.logger.debug("Test output:\n" + output) diff --git a/Tools/LyTestTools/ly_test_tools/launchers/platforms/android/launcher.py b/Tools/LyTestTools/ly_test_tools/launchers/platforms/android/launcher.py index 9433f426b5..846c21c568 100755 --- a/Tools/LyTestTools/ly_test_tools/launchers/platforms/android/launcher.py +++ b/Tools/LyTestTools/ly_test_tools/launchers/platforms/android/launcher.py @@ -280,7 +280,7 @@ class AndroidLauncher(Launcher): return True return False - def kill(self): + def _kill(self): """ Attempts to force quit any running processes with the stored package name on the device that is set to self._device_id via the self._adb_prefix_command diff --git a/Tools/LyTestTools/ly_test_tools/launchers/platforms/base.py b/Tools/LyTestTools/ly_test_tools/launchers/platforms/base.py index c47b9c8b67..430552f106 100755 --- a/Tools/LyTestTools/ly_test_tools/launchers/platforms/base.py +++ b/Tools/LyTestTools/ly_test_tools/launchers/platforms/base.py @@ -208,7 +208,7 @@ class Launcher(object): :return None: """ - self.kill() + self._kill() self.ensure_stopped() self.teardown() @@ -228,7 +228,7 @@ class Launcher(object): """ raise NotImplementedError("Launch is not implemented") - def kill(self): + def _kill(self): """ Force stop the launcher. @@ -274,7 +274,7 @@ class Launcher(object): timeout=timeout ) except ly_test_tools.launchers.exceptions.TeardownError: - self.kill() + self._kill() def get_device_config(self, config_file, device_section, device_key): """ diff --git a/Tools/LyTestTools/ly_test_tools/launchers/platforms/linux/launcher.py b/Tools/LyTestTools/ly_test_tools/launchers/platforms/linux/launcher.py index 377121f2e0..d6d6ae54c8 100644 --- a/Tools/LyTestTools/ly_test_tools/launchers/platforms/linux/launcher.py +++ b/Tools/LyTestTools/ly_test_tools/launchers/platforms/linux/launcher.py @@ -89,7 +89,7 @@ class LinuxLauncher(Launcher): self.restore_settings() super(LinuxLauncher, self).teardown() - def kill(self): + def _kill(self): """ This is a hard kill, and then wait to make sure until it actually ended. diff --git a/Tools/LyTestTools/ly_test_tools/launchers/platforms/mac/launcher.py b/Tools/LyTestTools/ly_test_tools/launchers/platforms/mac/launcher.py index 300e1f7a71..43f14c613a 100755 --- a/Tools/LyTestTools/ly_test_tools/launchers/platforms/mac/launcher.py +++ b/Tools/LyTestTools/ly_test_tools/launchers/platforms/mac/launcher.py @@ -44,7 +44,7 @@ class MacLauncher(Launcher): self._proc = subprocess.Popen(command) log.debug(f"Started Mac Launcher with command: {command}") - def kill(self): + def _kill(self): """ This is a hard kill, and then wait to make sure until it actually ended. diff --git a/Tools/LyTestTools/ly_test_tools/launchers/platforms/win/launcher.py b/Tools/LyTestTools/ly_test_tools/launchers/platforms/win/launcher.py index c29aa7b10b..ebdce2d52f 100755 --- a/Tools/LyTestTools/ly_test_tools/launchers/platforms/win/launcher.py +++ b/Tools/LyTestTools/ly_test_tools/launchers/platforms/win/launcher.py @@ -89,7 +89,7 @@ class WinLauncher(Launcher): self.restore_settings() super(WinLauncher, self).teardown() - def kill(self): + def _kill(self): """ This is a hard kill, and then wait to make sure until it actually ended. diff --git a/Tools/LyTestTools/ly_test_tools/o3de/editor_test.py b/Tools/LyTestTools/ly_test_tools/o3de/editor_test.py index 672259b076..f363689066 100644 --- a/Tools/LyTestTools/ly_test_tools/o3de/editor_test.py +++ b/Tools/LyTestTools/ly_test_tools/o3de/editor_test.py @@ -789,7 +789,7 @@ class EditorTestSuite(): test_result = Result.Fail.create(test_spec, output, editor_log_content) except WaitTimeoutError: output = editor.get_output() - editor.kill() + editor.stop() editor_log_content = editor_utils.retrieve_editor_log_content(run_id, log_name, workspace) test_result = Result.Timeout.create(test_spec, output, test_spec.timeout, editor_log_content) @@ -891,7 +891,7 @@ class EditorTestSuite(): results[test_spec_name] = Result.Crash.create(crashed_result.test_spec, output, return_code, crash_error, crashed_result.editor_log) except WaitTimeoutError: - editor.kill() + editor.stop() output = editor.get_output() editor_log_content = editor_utils.retrieve_editor_log_content(run_id, log_name, workspace) diff --git a/Tools/LyTestTools/tests/unit/test_launcher_android.py b/Tools/LyTestTools/tests/unit/test_launcher_android.py index d1adccb096..fa67a853d7 100755 --- a/Tools/LyTestTools/tests/unit/test_launcher_android.py +++ b/Tools/LyTestTools/tests/unit/test_launcher_android.py @@ -308,9 +308,11 @@ class TestAndroidLauncher: def test_Kill_HappyPath_KillCommandSuccess(self, mock_config, mock_call): mock_config.return_value = VALID_ANDROID_CONFIG mock_workspace = MockedWorkspace() - launcher = ly_test_tools.launchers.AndroidLauncher(mock_workspace, ["dummy"]) - launcher.kill() + + # This is a direct call to a protected method, but the point of the test is to ensure functionality of this + # protected method, so we will allow this exception + launcher._kill() mock_call.assert_called_once_with( ['adb', '-s', VALID_ANDROID_CONFIG['android']['id'], 'shell', 'am', 'force-stop', PACKAGE_NAME]) diff --git a/Tools/LyTestTools/tests/unit/test_launcher_base.py b/Tools/LyTestTools/tests/unit/test_launcher_base.py index 4fe72b889e..8633cc4008 100755 --- a/Tools/LyTestTools/tests/unit/test_launcher_base.py +++ b/Tools/LyTestTools/tests/unit/test_launcher_base.py @@ -52,7 +52,7 @@ class TestBaseLauncher: def test_Kill_Unimplemented_NotImplementedError(self): launcher = self.test_Construct_TestDoubles_BaseLauncherCreated() with pytest.raises(NotImplementedError): - launcher.kill() + launcher.stop() def test_Launch_Unimplemented_NotImplementedError(self): launcher = self.test_Construct_TestDoubles_BaseLauncherCreated() @@ -111,7 +111,7 @@ class TestBaseLauncher: with pytest.raises(NotImplementedError): launcher.stop() - @mock.patch('ly_test_tools.launchers.platforms.base.Launcher.kill') + @mock.patch('ly_test_tools.launchers.platforms.base.Launcher._kill') @mock.patch('ly_test_tools.launchers.platforms.base.Launcher.ensure_stopped') @mock.patch('ly_test_tools.launchers.platforms.base.Launcher.teardown') def test_Stop_MockImplementedLauncher_KillTeardown(self, mock_teardown, mock_ensure, mock_kill): diff --git a/Tools/LyTestTools/tests/unit/test_launcher_linux.py b/Tools/LyTestTools/tests/unit/test_launcher_linux.py index 2a6c6f7014..b40d2e2db3 100644 --- a/Tools/LyTestTools/tests/unit/test_launcher_linux.py +++ b/Tools/LyTestTools/tests/unit/test_launcher_linux.py @@ -57,7 +57,7 @@ class TestLinuxLauncher(object): launcher = ly_test_tools.launchers.LinuxLauncher(mock.MagicMock(), ["dummy"]) launcher._proc = mock_proc - launcher.kill() + launcher.stop() mock_proc.kill.assert_called_once() - mock_alive.assert_called_once() + mock_alive.assert_called() diff --git a/Tools/LyTestTools/tests/unit/test_launcher_mac.py b/Tools/LyTestTools/tests/unit/test_launcher_mac.py index bd9b776977..03b34cf4e3 100755 --- a/Tools/LyTestTools/tests/unit/test_launcher_mac.py +++ b/Tools/LyTestTools/tests/unit/test_launcher_mac.py @@ -62,7 +62,7 @@ class TestMacLauncher(object): launcher = ly_test_tools.launchers.MacLauncher(mock.MagicMock(), ["dummy"]) launcher._proc = mock_proc - launcher.kill() + launcher.stop() mock_proc.kill.assert_called_once() - mock_alive.assert_called_once() + mock_alive.assert_called() diff --git a/Tools/LyTestTools/tests/unit/test_launcher_win.py b/Tools/LyTestTools/tests/unit/test_launcher_win.py index 6dcb0cfdb4..15998a607a 100755 --- a/Tools/LyTestTools/tests/unit/test_launcher_win.py +++ b/Tools/LyTestTools/tests/unit/test_launcher_win.py @@ -56,10 +56,10 @@ class TestWinLauncher(object): launcher = ly_test_tools.launchers.WinLauncher(mock.MagicMock(), ["dummy"]) launcher._proc = mock_proc - launcher.kill() + launcher.stop() mock_proc.kill.assert_called_once() - mock_alive.assert_called_once() + mock_alive.assert_called() def test_IsAlive_NoProc_False(self): launcher = ly_test_tools.launchers.WinLauncher(mock.MagicMock(), ["dummy"]) diff --git a/Tools/LyTestTools/tests/unit/test_o3de_editor_test.py b/Tools/LyTestTools/tests/unit/test_o3de_editor_test.py index 054159cd16..973366aa94 100644 --- a/Tools/LyTestTools/tests/unit/test_o3de_editor_test.py +++ b/Tools/LyTestTools/tests/unit/test_o3de_editor_test.py @@ -694,7 +694,7 @@ class TestRunningTests(unittest.TestCase): 'mock_log_name', mock_test_spec, []) assert mock_cycle_crash.called assert mock_editor.start.called - assert mock_editor.kill.called + assert mock_editor.stop.called assert mock_create.called assert results == {mock_test_spec.__name__: mock_timeout}