Best Python code snippet using pyresttest_python
test_validators.py
Source:test_validators.py
...92 self.fail(93 'Type test comparator throws exception if you test against an undefined type')94 except TypeError:95 pass96 def test_safe_length(self):97 self.assertEqual(1, validators.safe_length('s'))98 self.assertEqual(2, validators.safe_length(['text', 2]))99 self.assertEqual(2, validators.safe_length({'key': 'val', 1: 2}))100 self.assertEqual(-1, validators.safe_length(False))101 self.assertEqual(-1, validators.safe_length(None))102 def test_validatortest_exists(self):103 func = validators.VALIDATOR_TESTS['exists']104 self.assertTrue(func('blah'))105 self.assertTrue(func(0))106 self.assertTrue(func('False'))107 self.assertTrue(func(False))108 self.assertFalse(func(None))109 def test_validatortest_not_exists(self):110 func = validators.VALIDATOR_TESTS['not_exists']...
test_walk.py
Source:test_walk.py
...12 self.assertTrue(np.min(rv) >= -j)13 print("%d %d-binomials: mean %f" % (size, j, np.mean(rv)))14 for size in [1, 2, 1000, 2000]:15 f(size)16 def test_safe_length(self):17 DISTANCE = 20018 length = walk.diagonal_walk_safe_length(DISTANCE, 0.01)19 def f():20 shape = (2, int(np.floor(length)))21 wa = 2*np.random.randint(0, 2, shape) - 122 wa = np.cumsum(wa, axis=1) # :(23 te = np.linalg.norm(wa, axis=0)24 return np.max(te) <= DISTANCE25 count = 026 TOTAL = 1000027 for i in range(TOTAL):28 if not f():29 count += 130 print("fraction:", count / TOTAL)...
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!!