Best Python code snippet using tempest_python
test_uworker.py
Source:test_uworker.py
...144 BaseExecutorTest.callback.last_message = msg145 def setUp(self):146 self.log = logs.get_logger('unittest', to_file=False, to_stdout=True)147class TestCommandExecutor(BaseExecutorTest):148 def test_execute_success(self):149 """Test execution that succeeds"""150 ce = uworker.CommandExecutor('Test', ['echo'], self.log)151 return_code, _ = ce.execute(['test_execute_success'],152 self.callback)153 self.assertEqual(return_code, 0)154 self.assertTrue('test_execute_success' in self.callback.last_message)155 def test_execute_failure(self):156 """Test execution that fails"""157 ce = uworker.CommandExecutor('Test', ['rm'], self.log)158 return_code, _ = ce.execute(['this.file.should.not.exist'],159 self.callback)160 self.assertEqual(return_code, 1)161 def test_timeout(self):162 """Test that process is killed if timeout"""163 ce = uworker.CommandExecutor('Test', ['sleep'], self.log)164 return_code, _ = ce.execute(['5'],165 self.callback, timeout=1, kill_after=1)166 self.assertNotEqual(return_code, 0)167 self.assertTrue('Killed Test process' in self.callback.last_message)168@pytest.mark.slow169class TestDockerExecutor(BaseExecutorTest):170 def test_image_pull(self):171 """Test pull of docker image"""172 de = uworker.DockerExecutor('Test', TEST_IMAGE, self.log)173 if de.image_exists():174 ce = uworker.CommandExecutor('Remove image', ['docker', 'rmi'],175 self.log)176 ce.execute([TEST_IMAGE], self.callback)177 self.assertFalse(de.image_exists())178 de.pull_image(self.callback)179 self.assertTrue(de.image_exists())180 def test_execute_success(self):181 """Test execution that succeeds"""182 de = uworker.DockerExecutor('Test', TEST_IMAGE, self.log)183 return_code, _ = de.execute(['echo', 'test_execute_success'],184 self.callback)185 self.assertEqual(return_code, 0)186 self.assertTrue('test_execute_success' in self.callback.last_message)187 def test_environment_variables(self):188 """Test provisioning of environment variables to container"""189 de = uworker.DockerExecutor(190 'Test', TEST_IMAGE, self.log,191 environment={'TESTENV': 'test_environment_variables'})192 return_code, _ = de.execute(['env'], self.callback)193 self.assertEqual(return_code, 0)194 self.assertTrue(...
chk_perm.py
Source:chk_perm.py
...155 Arguments:156 """157 os.mkdir(self.dir1)158 self.assertTrue(gen_libs.chk_perm(self.dir1, self.oct_perm2))159 def test_execute_success(self):160 """Function: test_execute_success161 Description: Test with execute permission checked successfully.162 Arguments:163 """164 os.mkdir(self.dir1)165 self.assertTrue(gen_libs.chk_perm(self.dir1, self.oct_perm7))166 def test_write_success(self):167 """Function: test_write_success168 Description: Test with write permission checked successfully.169 Arguments:170 """171 os.mkdir(self.dir1)172 self.assertTrue(gen_libs.chk_perm(self.dir1, self.oct_perm6))173 def test_read_success(self):...
test_commands.py
Source:test_commands.py
...7 commands.execute('xxxps auwwwx', 10)8 def test_execute_timeout(self):9 with self.assertRaises(commands.CommandTimeout):10 commands.execute('sleep 2', 1)11 def test_execute_success(self):12 out = commands.execute('echo test', 10)...
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!!