Best Python code snippet using responses
test_stop_criteria.py
Source:test_stop_criteria.py
...15 self.Criterion = GradientNormCriterion(2)16 def test_match(self):17 self.Criterion.accept(f, np.array([0.9]).reshape(-1, 1))18 self.assertTrue(self.Criterion.match())19 def test_not_match(self):20 self.Criterion.accept(f, np.array([2]).reshape(-1, 1))21 self.assertFalse(self.Criterion.match())22class ArgumentNormCriterionTests(TestCase):23 def setUp(self):24 self.Criterion = ArgumentNormCriterion(1)25 def test_match(self):26 self.Criterion.accept(f, np.array([0, 0.5]))27 self.Criterion.accept(f, np.array([0.5, 0]))28 self.assertTrue(self.Criterion.match())29 def test_not_match(self):30 self.Criterion.accept(f, np.array([0, 2]))31 self.assertFalse(self.Criterion.match())32 self.Criterion.accept(f, np.array([0, -2]))33 self.assertFalse(self.Criterion.match())34class FunctionNormCriterionTests(TestCase):35 def setUp(self):36 self.Criterion=FunctionNormCriterion(1)37 def test_match(self):38 self.Criterion.accept(f, np.array([0.9]))39 self.Criterion.accept(f, np.array([0.9]))40 self.assertTrue(self.Criterion.match())41 def test_not_match(self):42 self.Criterion.accept(f, np.array([2]))43 self.assertFalse(self.Criterion.match())44 self.Criterion.accept(f, np.array([4]))45 self.assertFalse(self.Criterion.match())46class AndCriterionTests(TestCase):47 def test_match(self):48 criterion=AndCriterion([IterationNumberCriterion(1),49 ArgumentNormCriterion(10**-3)])50 criterion.accept(f, np.array([0.9]))51 criterion.accept(f, np.array([0.9]))52 self.assertTrue(criterion.match())53 def test_not_match(self):54 criterion=AndCriterion([IterationNumberCriterion(1),55 ArgumentNormCriterion(10**-3)])56 criterion.accept(f, np.array([2]))57 criterion.accept(f, np.array([2.5]))58 self.assertFalse(criterion.match())59class OrCriterionTests(TestCase):60 def test_match(self):61 criterion=OrCriterion([IterationNumberCriterion(3),62 ArgumentNormCriterion(10**-3)])63 criterion.accept(f, np.array([2]))64 criterion.accept(f, np.array([2]))65 self.assertTrue(criterion.match())66 def test_not_match(self):67 criterion=OrCriterion([IterationNumberCriterion(3),68 ArgumentNormCriterion(10**-3)])69 criterion.accept(f, np.array([2]))70 criterion.accept(f, np.array([3]))...
prefix_test.py
Source:prefix_test.py
...67def test_exact_match():8 assert prefix_search({"category": "math", "cat": "animal"}, "cat") == {"category": "math", "cat": "animal"}910def test_not_match():11 with pytest.raises(KeyError):
...
test_git.py
Source:test_git.py
...3class GitRepoNewTests(unittest.TestCase):4 def test_match(self):5 message = {'topic': 'org.fedoraproject.dev.pagure.project.new'}6 self.assertTrue(git.git_repo_new({}, message))7 def test_not_match(self):8 message = {'topic': 'org.fedoraproject.dev.pagure.project.old'}...
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!!