Best Python code snippet using localstack_python
test_retries.py
Source:test_retries.py
...19import random20from testutil import Counter21import retries22class TestImmediateRetry(unittest.TestCase):23 def test_fallthrough(self):24 with Counter(self, 1) as counter:25 for retry in retries.ImmediateRetry():26 i = counter.bump()27 self.assertEqual(retry.count, i)28 self.assertEqual(int(retry), i)29 self.assertEqual(retry.need_retry, False)30 self.assertEqual(retry.count, 1)31 self.assertEqual(int(retry), 1)32 self.assertEqual(retry.need_retry, False)33 def test_immediate(self):34 with Counter(self, 2) as counter:35 for retry in retries.ImmediateRetry():36 i = counter.bump()37 self.assertEqual(retry.need_retry, False)38 if i == 0:39 retry.immediate()40 self.assertEqual(retry.need_retry, True)41 self.assertEqual(retry.count, i)42 self.assertEqual(int(retry), i)43 self.assertEqual(retry.count, 2)44 self.assertEqual(int(retry), 2)45 self.assertEqual(retry.need_retry, False)46 def test_later(self):47 self.assertEqual(retries.ImmediateRetry.later,48 retries.ImmediateRetry.immediate)49class TestBackoffRetry(unittest.TestCase):50 def sleep_func(self, wait_time_iter):51 def sf(time):52 try:53 expected = wait_time_iter.next()54 except StopIteration:55 self.fail('sleep func got StopIteration')56 self.assertEqual(time, expected)57 return sf58 def caffeine(self):59 return lambda t: self.fail('slept')60 def test_fallthrough(self):61 with Counter(self, 1) as counter:62 for retry in retries.BackoffRetry(iter([5]), self.caffeine()):63 i = counter.bump()64 self.assertEqual(retry.count, i)65 self.assertEqual(int(retry), i)66 self.assertEqual(retry.need_retry, False)67 self.assertEqual(retry.count, 1)68 self.assertEqual(int(retry), 1)69 self.assertEqual(retry.need_retry, False)70 def test_later(self):71 with Counter(self, 2) as counter:72 for retry in retries.BackoffRetry(iter([5]),73 self.sleep_func(iter([5]))):74 i = counter.bump()...
test_switch.py
Source:test_switch.py
...18 default: putstr("many"); break;19 }20 }21 ''', '0 is zero\n1 is one\n2 is many\n3 is many\n4 is many\n')22def test_fallthrough(check_output):23 check_output('''24 main() {25 extrn putchar;;26 auto i;27 i = 0; while(i <= 4) {28 describe(i);29 putchar('*n');30 ++i;31 }32 }33 describe(val) {34 extrn putstr, putnumb;35 putnumb(val); putstr(" is ");36 switch(val) {...
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!!