Best Python code snippet using autotest_python
subcommand_unittest.py
Source:subcommand_unittest.py
...151 .and_return((1000, 10)))152 cmd._handle_exitstatus.expect_call(10).and_raises(Exception('fail'))153 self.assertRaises(Exception, cmd.wait)154 self.god.check_playback()155 def _setup_fork_waitfor(self):156 cmd = self._setup_fork_start_parent()157 self.god.stub_function(cmd, 'wait')158 self.god.stub_function(cmd, 'poll')159 self.god.stub_function(subcommand.time, 'time')160 self.god.stub_function(subcommand.time, 'sleep')161 self.god.stub_function(subcommand.utils, 'nuke_pid')162 return cmd163 def test_fork_waitfor_no_timeout(self):164 cmd = self._setup_fork_waitfor()165 cmd.wait.expect_call().and_return(0)166 self.assertEquals(cmd.fork_waitfor(), 0)167 self.god.check_playback()168 def test_fork_waitfor_success(self):169 cmd = self._setup_fork_waitfor()170 self.god.stub_function(cmd, 'wait')171 timeout = 10172 subcommand.time.time.expect_call().and_return(1)173 for i in xrange(timeout):174 subcommand.time.time.expect_call().and_return(i + 1)175 cmd.poll.expect_call().and_return(None)176 subcommand.time.sleep.expect_call(1)177 subcommand.time.time.expect_call().and_return(i + 2)178 cmd.poll.expect_call().and_return(0)179 self.assertEquals(cmd.fork_waitfor(timeout=timeout), 0)180 self.god.check_playback()181 def test_fork_waitfor_failure(self):182 cmd = self._setup_fork_waitfor()183 self.god.stub_function(cmd, 'wait')184 timeout = 10185 subcommand.time.time.expect_call().and_return(1)186 for i in xrange(timeout):187 subcommand.time.time.expect_call().and_return(i + 1)188 cmd.poll.expect_call().and_return(None)189 subcommand.time.sleep.expect_call(1)190 subcommand.time.time.expect_call().and_return(i + 3)191 subcommand.utils.nuke_pid.expect_call(cmd.pid)192 self.assertEquals(cmd.fork_waitfor(timeout=timeout), None)193 self.god.check_playback()194class parallel_test(unittest.TestCase):195 def setUp(self):196 self.god = mock.mock_god()...
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!!