How to use _register_subcommand_hooks method in autotest

Best Python code snippet using autotest_python Github


Full Screen

...191 self.pkgmgr = packages.PackageManager(192 self.autodir, run_function_dargs={'timeout': 600})193 self.num_tests_run = 0194 self.num_tests_failed = 0195 self._register_subcommand_hooks()196 # these components aren't usable on the server197 self.bootloader = None198 self.harness = None199 # set up the status logger200 self._indenter = status_indenter()201 self._logger = base_job.status_logger(202 self, self._indenter, 'status.log', 'status.log',203 record_hook=server_job_record_hook(self))204 @classmethod205 # The unittests will hide this method, well, for unittesting206 # pylint: disable=E0202207 def _find_base_directories(cls):208 """209 Determine locations of autodir, clientdir and serverdir. Assumes210 that this file is located within serverdir and uses __file__ along211 with relative paths to resolve the location.212 """213 serverdir = os.path.abspath(os.path.dirname(__file__))214 autodir = os.path.normpath(os.path.join(serverdir, '..'))215 clientdir = os.path.join(autodir, 'client')216 return autodir, clientdir, serverdir217 # The unittests will hide this method, well, for unittesting218 # pylint: disable=E0202219 def _find_resultdir(self, resultdir):220 """221 Determine the location of resultdir. For server jobs we expect one to222 always be explicitly passed in to __init__, so just return that.223 """224 if resultdir:225 return os.path.normpath(resultdir)226 else:227 return None228 def _get_status_logger(self):229 """Return a reference to the status logger."""230 return self._logger231 @staticmethod232 def _load_control_file(path):233 f = open(path)234 try:235 control_file = finally:237 f.close()238 return re.sub('\r', '', control_file)239 def _register_subcommand_hooks(self):240 """241 Register some hooks into the subcommand modules that allow us242 to properly clean up self.hosts created in forked subprocesses.243 """244 def on_fork(cmd):245 self._existing_hosts_on_fork = set(self.hosts)246 def on_join(cmd):247 new_hosts = self.hosts - self._existing_hosts_on_fork248 for host in new_hosts:249 host.close()250 subcommand.subcommand.register_fork_hook(on_fork)251 subcommand.subcommand.register_join_hook(on_join)252 def init_parser(self):253 """...

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:


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?