Changed kill() to protected. Changed references from kill() to stop().

Signed-off-by: scspaldi <scspaldi@amazon.com>
monroegm-disable-blank-issue-2
scspaldi 4 years ago
parent 5509764fc2
commit 92da291bb4

@ -78,7 +78,7 @@ class TestAutomationBase:
file_system.restore_backup(workspace.paths.editor_log(), workspace.paths.project_log()) file_system.restore_backup(workspace.paths.editor_log(), workspace.paths.project_log())
except FileNotFoundError as e: except FileNotFoundError as e:
self.logger.debug(f"File restoration failed, editor log could not be found.\nError: {e}") self.logger.debug(f"File restoration failed, editor log could not be found.\nError: {e}")
editor.kill() editor.stop()
request.addfinalizer(teardown) request.addfinalizer(teardown)
@ -113,7 +113,7 @@ class TestAutomationBase:
editor.wait(TestAutomationBase.MAX_TIMEOUT) editor.wait(TestAutomationBase.MAX_TIMEOUT)
except WaitTimeoutError: 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")) 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() output = editor.get_output()
self.logger.debug("Test output:\n" + output) self.logger.debug("Test output:\n" + output)

@ -280,7 +280,7 @@ class AndroidLauncher(Launcher):
return True return True
return False return False
def kill(self): def _kill(self):
""" """
Attempts to force quit any running processes with the stored package name on the device 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 that is set to self._device_id via the self._adb_prefix_command

@ -208,7 +208,7 @@ class Launcher(object):
:return None: :return None:
""" """
self.kill() self._kill()
self.ensure_stopped() self.ensure_stopped()
self.teardown() self.teardown()
@ -228,7 +228,7 @@ class Launcher(object):
""" """
raise NotImplementedError("Launch is not implemented") raise NotImplementedError("Launch is not implemented")
def kill(self): def _kill(self):
""" """
Force stop the launcher. Force stop the launcher.
@ -274,7 +274,7 @@ class Launcher(object):
timeout=timeout timeout=timeout
) )
except ly_test_tools.launchers.exceptions.TeardownError: except ly_test_tools.launchers.exceptions.TeardownError:
self.kill() self._kill()
def get_device_config(self, config_file, device_section, device_key): def get_device_config(self, config_file, device_section, device_key):
""" """

@ -89,7 +89,7 @@ class LinuxLauncher(Launcher):
self.restore_settings() self.restore_settings()
super(LinuxLauncher, self).teardown() 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. This is a hard kill, and then wait to make sure until it actually ended.

@ -44,7 +44,7 @@ class MacLauncher(Launcher):
self._proc = subprocess.Popen(command) self._proc = subprocess.Popen(command)
log.debug(f"Started Mac Launcher with command: {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. This is a hard kill, and then wait to make sure until it actually ended.

@ -89,7 +89,7 @@ class WinLauncher(Launcher):
self.restore_settings() self.restore_settings()
super(WinLauncher, self).teardown() 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. This is a hard kill, and then wait to make sure until it actually ended.

@ -789,7 +789,7 @@ class EditorTestSuite():
test_result = Result.Fail.create(test_spec, output, editor_log_content) test_result = Result.Fail.create(test_spec, output, editor_log_content)
except WaitTimeoutError: except WaitTimeoutError:
output = editor.get_output() output = editor.get_output()
editor.kill() editor.stop()
editor_log_content = editor_utils.retrieve_editor_log_content(run_id, log_name, workspace) 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) 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, results[test_spec_name] = Result.Crash.create(crashed_result.test_spec, output, return_code,
crash_error, crashed_result.editor_log) crash_error, crashed_result.editor_log)
except WaitTimeoutError: except WaitTimeoutError:
editor.kill() editor.stop()
output = editor.get_output() output = editor.get_output()
editor_log_content = editor_utils.retrieve_editor_log_content(run_id, log_name, workspace) editor_log_content = editor_utils.retrieve_editor_log_content(run_id, log_name, workspace)

@ -308,9 +308,11 @@ class TestAndroidLauncher:
def test_Kill_HappyPath_KillCommandSuccess(self, mock_config, mock_call): def test_Kill_HappyPath_KillCommandSuccess(self, mock_config, mock_call):
mock_config.return_value = VALID_ANDROID_CONFIG mock_config.return_value = VALID_ANDROID_CONFIG
mock_workspace = MockedWorkspace() mock_workspace = MockedWorkspace()
launcher = ly_test_tools.launchers.AndroidLauncher(mock_workspace, ["dummy"]) 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( mock_call.assert_called_once_with(
['adb', '-s', VALID_ANDROID_CONFIG['android']['id'], 'shell', 'am', 'force-stop', PACKAGE_NAME]) ['adb', '-s', VALID_ANDROID_CONFIG['android']['id'], 'shell', 'am', 'force-stop', PACKAGE_NAME])

@ -52,7 +52,7 @@ class TestBaseLauncher:
def test_Kill_Unimplemented_NotImplementedError(self): def test_Kill_Unimplemented_NotImplementedError(self):
launcher = self.test_Construct_TestDoubles_BaseLauncherCreated() launcher = self.test_Construct_TestDoubles_BaseLauncherCreated()
with pytest.raises(NotImplementedError): with pytest.raises(NotImplementedError):
launcher.kill() launcher.stop()
def test_Launch_Unimplemented_NotImplementedError(self): def test_Launch_Unimplemented_NotImplementedError(self):
launcher = self.test_Construct_TestDoubles_BaseLauncherCreated() launcher = self.test_Construct_TestDoubles_BaseLauncherCreated()
@ -111,7 +111,7 @@ class TestBaseLauncher:
with pytest.raises(NotImplementedError): with pytest.raises(NotImplementedError):
launcher.stop() 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.ensure_stopped')
@mock.patch('ly_test_tools.launchers.platforms.base.Launcher.teardown') @mock.patch('ly_test_tools.launchers.platforms.base.Launcher.teardown')
def test_Stop_MockImplementedLauncher_KillTeardown(self, mock_teardown, mock_ensure, mock_kill): def test_Stop_MockImplementedLauncher_KillTeardown(self, mock_teardown, mock_ensure, mock_kill):

@ -57,7 +57,7 @@ class TestLinuxLauncher(object):
launcher = ly_test_tools.launchers.LinuxLauncher(mock.MagicMock(), ["dummy"]) launcher = ly_test_tools.launchers.LinuxLauncher(mock.MagicMock(), ["dummy"])
launcher._proc = mock_proc launcher._proc = mock_proc
launcher.kill() launcher.stop()
mock_proc.kill.assert_called_once() mock_proc.kill.assert_called_once()
mock_alive.assert_called_once() mock_alive.assert_called()

@ -62,7 +62,7 @@ class TestMacLauncher(object):
launcher = ly_test_tools.launchers.MacLauncher(mock.MagicMock(), ["dummy"]) launcher = ly_test_tools.launchers.MacLauncher(mock.MagicMock(), ["dummy"])
launcher._proc = mock_proc launcher._proc = mock_proc
launcher.kill() launcher.stop()
mock_proc.kill.assert_called_once() mock_proc.kill.assert_called_once()
mock_alive.assert_called_once() mock_alive.assert_called()

@ -56,10 +56,10 @@ class TestWinLauncher(object):
launcher = ly_test_tools.launchers.WinLauncher(mock.MagicMock(), ["dummy"]) launcher = ly_test_tools.launchers.WinLauncher(mock.MagicMock(), ["dummy"])
launcher._proc = mock_proc launcher._proc = mock_proc
launcher.kill() launcher.stop()
mock_proc.kill.assert_called_once() mock_proc.kill.assert_called_once()
mock_alive.assert_called_once() mock_alive.assert_called()
def test_IsAlive_NoProc_False(self): def test_IsAlive_NoProc_False(self):
launcher = ly_test_tools.launchers.WinLauncher(mock.MagicMock(), ["dummy"]) launcher = ly_test_tools.launchers.WinLauncher(mock.MagicMock(), ["dummy"])

@ -694,7 +694,7 @@ class TestRunningTests(unittest.TestCase):
'mock_log_name', mock_test_spec, []) 'mock_log_name', mock_test_spec, [])
assert mock_cycle_crash.called assert mock_cycle_crash.called
assert mock_editor.start.called assert mock_editor.start.called
assert mock_editor.kill.called assert mock_editor.stop.called
assert mock_create.called assert mock_create.called
assert results == {mock_test_spec.__name__: mock_timeout} assert results == {mock_test_spec.__name__: mock_timeout}

Loading…
Cancel
Save