How to use _parse_hosts method in autotest

Best Python code snippet using autotest_python

udp.py

Source: udp.py Github

copy

Full Screen

...30 self.__ns = ns31 self.__socket = None32 self.__sending = False33 self.__metrics = {}34 self.__endpoints = self._parse_hosts(hosts)35 self.__add_metric(metrics.HeartBeat)36 @staticmethod37 def _parse_hosts(hosts):38 endpoints = list()39 for host_str in hosts.split(","):40 if ":" in host_str:41 host, port = host_str.split(":", 1)42 port = int(port)43 else:44 host, port = host_str, 200345 if not isinstance(host, str):46 host = host.decode()47 endpoints.append((host, port))48 return frozenset(endpoints)49 @property50 def hosts(self):51 return self.__endpoints52 @hosts.setter53 @LOCK54 def hosts(self, hosts):55 self.__endpoints = self._parse_hosts(hosts)56 @property57 def ns(self):58 return self.__ns59 @ns.setter60 def ns(self, ns):61 if ns.startswith('.'):62 raise ValueError("NameSpace mustn't starts with the dot.")63 if ns.endswith('.'):64 raise ValueError("NameSpace mustn't ends with the dot.")65 if re.match('^[\w\d\._\-]+$', ns) is None:66 raise ValueError("NameSpace mustn't contain special chars (except '_', '-')")67 if bool(list(filter(lambda x: not x, ns.split('.')))):68 raise ValueError("Namespace must contain chars after dots.")69 self.__ns = ns...

Full Screen

Full Screen

__init__.py

Source: __init__.py Github

copy

Full Screen

...62 except Exception as err:63 breakpoint() # get exception class64 raise NetmapParseError("", (err,))65 return host66 def _parse_hosts(hosts):67 if isinstance(hosts, (list, tuple, iter)):68 return [_parse_hosts(host)69 for host in hosts]70 if isinstance(hosts, (str,)):71 pass72 def _coerce_ports(port_or_ports):73 ports = None74 if isinstance(port_or_ports, int):75 ports = [port_or_ports]76 if isinstance(port_or_ports, (list, tuple, set,)):77 ports = list(port_or_ports)78 if not all([isinstance(p, int) for p in ports]):79 raise NetmapParseError(80 "recursive port coercion unimpl"81 )82 if ports is None:83 raise NetmapParseError()84 return ports85 single_host = None86 try:87 single_host = _parse_host(host_or_hosts)88 except NetmapParseError:89 pass90 if single_host is not None:91 hosts = [single_host]92 else:93 hosts = _parse_hosts(host_or_hosts)94 rv = {}95 for host in hosts:96 print("scanning host", host)97 single_host_res = _port_scan_single_host(host,98 # ports,99 _coerce_ports(ports),100 )101 rv.update(**{str(host): single_host_res})102 breakpoint()...

Full Screen

Full Screen

test_etcd_driver.py

Source: test_etcd_driver.py Github

copy

Full Screen

...15class TestEtcdDB(tests_base.BaseTestCase):16 def test_parse_none(self):17 fake_host = []18 expected = ()19 output = etcd_db_driver._parse_hosts(fake_host)20 self.assertEqual(expected, output)21 def test_parse_empty(self):22 fake_host = [""]23 expected = ()24 output = etcd_db_driver._parse_hosts(fake_host)25 self.assertEqual(expected, output)26 def test_parse_one_host(self):27 fake_host = ['127.0.0.1:80']28 expected = (('127.0.0.1', 80),)29 output = etcd_db_driver._parse_hosts(fake_host)30 self.assertEqual(expected, output)31 def test_parse_multiple_hosts(self):32 fake_host = ['127.0.0.1:80', '192.168.0.1:8080']33 expected = (('127.0.0.1', 80), ('192.168.0.1', 8080))34 output = etcd_db_driver._parse_hosts(fake_host)35 self.assertEqual(expected, output)36 def test_parse_multiple_hosts_invalid(self):37 fake_host = ['127.0.0.1:80', '192.168.0.1']38 expected = (('127.0.0.1', 80),)39 with mock.patch.object(etcd_db_driver.LOG, 'error') as log_err:40 output = etcd_db_driver._parse_hosts(fake_host)41 self.assertEqual(expected, output)42 log_err.assert_called_once_with(...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

How To Choose The Best JavaScript Unit Testing Frameworks

JavaScript is one of the most widely used programming languages. This popularity invites a lot of JavaScript development and testing frameworks to ease the process of working with it. As a result, numerous JavaScript testing frameworks can be used to perform unit testing.

10 Best Software Testing Certifications To Take In 2021

Software testing is fueling the IT sector forward by scaling up the test process and continuous product delivery. Currently, this profession is in huge demand, as it needs certified testers with expertise in automation testing. When it comes to outsourcing software testing jobs, whether it’s an IT company or an individual customer, they all look for accredited professionals. That’s why having an software testing certification has become the need of the hour for the folks interested in the test automation field. A well-known certificate issued by an authorized institute kind vouches that the certificate holder is skilled in a specific technology.

Feeding your QA Career – Developing Instinctive & Practical Skills

The QA testing profession requires both educational and long-term or experience-based learning. One can learn the basics from certification courses and exams, boot camp courses, and college-level courses where available. However, developing instinctive and practical skills works best when built with work experience.

Assessing Risks in the Scrum Framework

Software Risk Management (SRM) combines a set of tools, processes, and methods for managing risks in the software development lifecycle. In SRM, we want to make informed decisions about what can go wrong at various levels within a company (e.g., business, project, and software related).

Test strategy and how to communicate it

I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.

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