Best Python code snippet using tempest_python
test_data_utils.py
Source:test_data_utils.py
...71 # are different each other. But only 3 letters can be the same value72 # in a very rare case. So, we just check the length here, too,73 # just in case.74 self.assertEqual(len(actual2), 3)75 def test_rand_url(self):76 actual = data_utils.rand_url()77 self.assertIsInstance(actual, str)78 self.assertRegex(actual, r"^https://url-[0-9]*\.com$")79 actual2 = data_utils.rand_url()80 self.assertNotEqual(actual, actual2)81 def test_rand_int(self):82 actual = data_utils.rand_int_id()83 self.assertIsInstance(actual, int)84 actual2 = data_utils.rand_int_id()85 self.assertNotEqual(actual, actual2)86 def test_rand_infiniband_guid_address(self):87 actual = data_utils.rand_infiniband_guid_address()88 self.assertIsInstance(actual, str)89 self.assertRegex(actual, "^([0-9a-f][0-9a-f]:){7}"...
event_generator_test.py
Source:event_generator_test.py
...36 fnames = map(f, app_util.load_data('fnames.txt'))37 lnames = map(f, app_util.load_data('lnames.txt'))38 self.assertTrue(fname in fnames, 'Invalid first name \'%s\'' % fname)39 self.assertTrue(lname in lnames, 'Invalid last name \'%s\'' % lname)40 def test_rand_url(self):41 url = event_generator.rand_url()42 self.assertIsNotNone(url)43 # The url conforms to the expected format44 self.assertTrue(re.match('^http[s]?://www\.\w[-]?\w.*(jpg|png|html|xml|php|asp)$', url),45 'Invalid URL \'%s\'' % url)46 def test_rand_http_status(self):47 status = event_generator.rand_http_status()48 self.assertTrue(status in map(lambda x: int(x),49 (200, 302, 404, 500, 502, 503)),50 'Invalid HTTP status: %s' % status)51 def test_rand_res_size(self):52 size = event_generator.rand_res_size()53 self.assertTrue(1 <= size <= 5000000, 'Invalid resource size: %d' % size)54 def test_create_event(self):...
check_online_status.py
Source:check_online_status.py
...98adobe.com99about.google100businessinsider.com101goodhousekeeping.com""".split("\n")102def test_rand_url():103 r = requests.get(random.choice(URLLIST))104 if r.status_code == 200:105 return True106 return False107def wait_for_connection(test_delay):108 r = 0109 while r == 0:110 try:111 r = requests.get("https://" + random.choice(URLLIST), timeout=2.0).status_code112 except requests.exceptions.ConnectionError:113 r = 0114 except requests.exceptions.ReadTimeout:115 r = 0116 if r == 0:...
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!!