How to use _grab_fd_info method in autotest

Best Python code snippet using autotest_python

logging_manager_unittest.py

Source:logging_manager_unittest.py Github

copy

Full Screen

...142 manager.undo_redirect()143 self._say(6)144 manager.stop_logging()145 self._say(7)146 def _grab_fd_info(self):147 command = 'ls -l /proc/%s/fd' % os.getpid()148 proc = subprocess.Popen(command.split(), shell=True,149 stdout=subprocess.PIPE)150 return proc.communicate()[0]151 def _compare_logs(self, log_buffer, expected_text):152 actual_lines = log_buffer.getvalue().splitlines()153 expected_lines = expected_text.splitlines()154 if self._real_system_calls:155 # because of the many interacting processes, we can't ensure perfect156 # interleaving. so compare sets of lines rather than ordered lines.157 actual_lines = set(actual_lines)158 expected_lines = set(expected_lines)159 self.assertEquals(actual_lines, expected_lines)160 def _check_results(self):161 # ensure our stdout was restored162 self.assertEquals(self.stdout, self._original_stdout)163 if self._real_system_calls:164 # ensure FDs were left in their original state165 self.assertEquals(self._grab_fd_info(), self._fd_info)166 self._compare_logs(self.stdout, _EXPECTED_STDOUT)167 self._compare_logs(self._log1, _EXPECTED_LOG1)168 self._compare_logs(self._log2, _EXPECTED_LOG2)169 @unittest.skip("logging manager does not behave well under nosetests")170 def test_logging_manager(self):171 self._run_test(logging_manager.LoggingManager)172 self._check_results()173 @unittest.skip("logging manager does not behave well under nosetests")174 def test_fd_redirection_logging_manager(self):175 self._real_system_calls = True176 self._fd_info = self._grab_fd_info()177 self._run_test(logging_manager.FdRedirectionLoggingManager)178 self._check_results()179 @unittest.skip("logging manager does not behave well under nosetests")180 def test_tee_redirect_debug_dir(self):181 manager = self._setup_manager()182 manager.start_logging()183 manager.tee_redirect_debug_dir('/fake/dir', tag='mytag')184 print >>self.stdout, 'hello'185 manager.undo_redirect()186 print >>self.stdout, 'goodbye'187 manager.stop_logging()188 self._compare_logs(self.stdout,189 'INFO: mytag : hello\nINFO: goodbye')190 self._compare_logs(self._config_object.log, 'hello\n')...

Full Screen

Full Screen

logging_manager_test.py

Source:logging_manager_test.py Github

copy

Full Screen

...134 manager.undo_redirect()135 self._say(6)136 manager.stop_logging()137 self._say(7)138 def _grab_fd_info(self):139 command = 'ls -l /proc/%s/fd' % os.getpid()140 proc = subprocess.Popen(command.split(), shell=True,141 stdout=subprocess.PIPE)142 return proc.communicate()[0]143 def _compare_logs(self, log_buffer, expected_text):144 actual_lines = log_buffer.getvalue().splitlines()145 expected_lines = expected_text.splitlines()146 if self._real_system_calls:147 # because of the many interacting processes, we can't ensure perfect148 # interleaving. so compare sets of lines rather than ordered lines.149 actual_lines = set(actual_lines)150 expected_lines = set(expected_lines)151 self.assertEquals(actual_lines, expected_lines)152 def _check_results(self):153 # ensure our stdout was restored154 self.assertEquals(self.stdout, self._original_stdout)155 if self._real_system_calls:156 # ensure FDs were left in their original state157 self.assertEquals(self._grab_fd_info(), self._fd_info)158 self._compare_logs(self.stdout, _EXPECTED_STDOUT)159 self._compare_logs(self._log1, _EXPECTED_LOG1)160 self._compare_logs(self._log2, _EXPECTED_LOG2)161 def test_logging_manager(self):162 self._run_test(logging_manager.LoggingManager)163 self._check_results()164 def test_fd_redirection_logging_manager(self):165 self._real_system_calls = True166 self._fd_info = self._grab_fd_info()167 self._run_test(logging_manager.FdRedirectionLoggingManager)168 self._check_results()169 def test_tee_redirect_debug_dir(self):170 manager = self._setup_manager()171 manager.start_logging()172 manager.tee_redirect_debug_dir('/fake/dir', tag='mytag')173 print >>self.stdout, 'hello'174 manager.undo_redirect()175 print >>self.stdout, 'goodbye'176 manager.stop_logging()177 self._compare_logs(self.stdout,178 'INFO: mytag : hello\nINFO: goodbye')179 self._compare_logs(self._config_object.log, 'hello\n')180class MonkeyPatchTestCase(unittest.TestCase):...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful