Best Python code snippet using autotest_python
monitor_db_unittest.py
Source:monitor_db_unittest.py
...406 self.pidfile_id, use_second_read=use_second_read).and_return(407 contents)408 def set_not_yet_run(self):409 self.setup_pidfile()410 def set_empty_pidfile(self):411 self.setup_pidfile()412 def set_running(self, use_second_read=False):413 self.setup_pidfile(self.pid, use_second_read=use_second_read)414 def set_complete(self, error_code, use_second_read=False):415 self.setup_pidfile(self.pid, error_code, self.num_tests_failed,416 use_second_read=use_second_read)417 def _check_monitor(self, expected_pid, expected_exit_status,418 expected_num_tests_failed):419 if expected_pid is None:420 self.assertEquals(self.monitor._state.process, None)421 else:422 self.assertEquals(self.monitor._state.process.pid, expected_pid)423 self.assertEquals(self.monitor._state.exit_status, expected_exit_status)424 self.assertEquals(self.monitor._state.num_tests_failed,425 expected_num_tests_failed)426 self.god.check_playback()427 def _test_read_pidfile_helper(self, expected_pid, expected_exit_status,428 expected_num_tests_failed):429 self.monitor._read_pidfile()430 self._check_monitor(expected_pid, expected_exit_status,431 expected_num_tests_failed)432 def _get_expected_tests_failed(self, expected_exit_status):433 if expected_exit_status is None:434 expected_tests_failed = None435 else:436 expected_tests_failed = self.num_tests_failed437 return expected_tests_failed438 def test_read_pidfile(self):439 self.set_not_yet_run()440 self._test_read_pidfile_helper(None, None, None)441 self.set_empty_pidfile()442 self._test_read_pidfile_helper(None, None, None)443 self.set_running()444 self._test_read_pidfile_helper(self.pid, None, None)445 self.set_complete(123)446 self._test_read_pidfile_helper(self.pid, 123, self.num_tests_failed)447 def test_read_pidfile_error(self):448 self.mock_drone_manager.get_pidfile_contents.expect_call(449 self.pidfile_id, use_second_read=False).and_return(450 drone_manager.InvalidPidfile('error'))451 self.assertRaises(pidfile_monitor.PidfileRunMonitor._PidfileException,452 self.monitor._read_pidfile)453 self.god.check_playback()454 def setup_is_running(self, is_running):455 self.mock_drone_manager.is_process_running.expect_call(...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!