Best Python code snippet using autotest_python
recover_hosts.py
Source: recover_hosts.py
...12 def recover_():13 hosts = HostsToRecover._get_hosts_to_recover(scope='function')14 if hosts:15 HostsToRecover._reset('function')16 HostsToRecover._recover_hosts(hosts, 'function')17 request.addfinalizer(recover_)18@fixture(scope='class', autouse=True)19def hosts_recover_class(request):20 def recover_hosts():21 hosts = HostsToRecover._get_hosts_to_recover(scope='class')22 if hosts:23 HostsToRecover._reset('class')24 HostsToRecover._recover_hosts(hosts, 'class')25 request.addfinalizer(recover_hosts)26@fixture(scope='module', autouse=True)27def hosts_recover_module(request):28 def recover_hosts():29 hosts = HostsToRecover._get_hosts_to_recover(scope='module')30 if hosts:31 HostsToRecover._reset('module')32 HostsToRecover._recover_hosts(hosts, 'module')33 request.addfinalizer(recover_hosts)34class HostsToRecover():35 __hosts_to_recover = {36 'function': [],37 'class': [],38 'module': [],39 }40 @classmethod41 def __check_scope(cls, scope):42 valid_scope = cls.__hosts_to_recover.keys()43 if scope not in valid_scope:44 raise ValueError(45 "scope has to be one of the following: {}".format(valid_scope))46 @classmethod47 def add(cls, hostnames, scope='function'):48 """49 Add host(s) to recover list. Will wait for host(s) to recover as test50 teardown.51 Args:52 hostnames (str|list):53 scope54 """55 if scope is None:56 return57 cls.__check_scope(scope)58 if isinstance(hostnames, str):59 hostnames = [hostnames]60 cls.__hosts_to_recover[scope] += hostnames61 @classmethod62 def remove(cls, hostnames, scope='function'):63 """64 Remove host(s) from recover list. Only remove one instance if host65 has multiple occurances in the recover list.66 Args:67 hostnames (str|list|tuple):68 scope:69 """70 if scope is None:71 return72 cls.__check_scope(scope)73 if isinstance(hostnames, str):74 hostnames = [hostnames]75 for host in hostnames:76 cls.__hosts_to_recover[scope].remove(host)77 @classmethod78 def _reset(cls, scope):79 cls.__hosts_to_recover[scope] = []80 @classmethod81 def _get_hosts_to_recover(cls, scope):82 return list(cls.__hosts_to_recover[scope])83 @staticmethod84 def _recover_hosts(hostnames, scope):85 if system_helper.is_aio_simplex():86 LOG.fixture_step('{} Recover simplex host'.format(scope))87 host_helper.recover_simplex(fail_ok=False)88 return89 # Recover hosts for non-simplex system90 hostnames = sorted(set(hostnames))91 table_ = table_parser.table(cli.system('host-list')[1])92 table_ = table_parser.filter_table(table_, hostname=hostnames)93 # unlocked_hosts = table_parser.get_values(table_, 'hostname',94 # administrative='unlocked')95 locked_hosts = table_parser.get_values(table_, 'hostname',96 administrative='locked')97 err_msg = []98 if locked_hosts:...
Check out the latest blogs from LambdaTest on this topic:
Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.
So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.
Did you know that according to Statista, the number of smartphone users will reach 18.22 billion by 2025? Let’s face it, digital transformation is skyrocketing and will continue to do so. This swamps the mobile app development market with various options and gives rise to the need for the best mobile app testing tools
As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????
The count of mobile users is on a steep rise. According to the research, by 2025, it is expected to reach 7.49 billion users worldwide. 70% of all US digital media time comes from mobile apps, and to your surprise, the average smartphone owner uses ten apps per day and 30 apps each month.
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!!