Best Python code snippet using robotframework-pageobjects_python
test_pycryptosat.py
Source:test_pycryptosat.py
...62# -------------------------- actual unit tests ---------------------------63class TestXor(unittest.TestCase):64 def setUp(self):65 self.solver = Solver(threads=2)66 def test_wrong_args(self):67 self.assertRaises(TypeError, self.solver.add_xor_clause, [1, 2])68 self.assertRaises(ValueError, self.solver.add_xor_clause, [1, 0], True)69 self.assertRaises(70 ValueError, self.solver.add_xor_clause, [-1, 2], True)71 def test_binary(self):72 self.solver.add_xor_clause([1, 2], False)73 res, solution = self.solver.solve([1])74 self.assertEqual(res, True)75 self.assertEqual(solution, (None, True, True))76 def test_unit(self):77 self.solver.add_xor_clause([1], False)78 res, solution = self.solver.solve()79 self.assertEqual(res, True)80 self.assertEqual(solution, (None, False))81 def test_unit2(self):82 self.solver.add_xor_clause([1], True)83 res, solution = self.solver.solve()84 self.assertEqual(res, True)85 self.assertEqual(solution, (None, True))86 def test_3_long(self):87 self.solver.add_xor_clause([1, 2, 3], False)88 res, solution = self.solver.solve([1, 2])89 self.assertEqual(res, True)90 # self.assertEqual(solution, (None, True, True, False))91 def test_3_long2(self):92 self.solver.add_xor_clause([1, 2, 3], True)93 res, solution = self.solver.solve([1, -2])94 self.assertEqual(res, True)95 self.assertEqual(solution, (None, True, False, False))96 def test_long(self):97 for l in range(10, 30):98 self.setUp()99 toadd = []100 toassume = []101 solution_expected = [None]102 for i in range(1, l):103 toadd.append(i)104 solution_expected.append(False)105 if i != l - 1:106 toassume.append(i * -1)107 self.solver.add_xor_clause(toadd, False)108 res, solution = self.solver.solve(toassume)109 self.assertEqual(res, True)110 self.assertEqual(solution, tuple(solution_expected))111class InitTester(unittest.TestCase):112 def test_wrong_args_to_solver(self):113 self.assertRaises(ValueError, Solver, threads=-1)114 self.assertRaises(ValueError, Solver, threads=0)115 self.assertRaises(ValueError, Solver, verbose=-1)116 self.assertRaises(ValueError, Solver, confl_limit=-1)117 self.assertRaises(TypeError, Solver, threads="fail")118 self.assertRaises(TypeError, Solver, verbose="fail")119 self.assertRaises(TypeError, Solver, confl_limit="fail")120class TestSolve(unittest.TestCase):121 def setUp(self):122 self.solver = Solver(threads=2)123 def test_wrong_args(self):124 self.assertRaises(TypeError, self.solver.add_clause, 'A')125 self.assertRaises(TypeError, self.solver.add_clause, 1)126 self.assertRaises(TypeError, self.solver.add_clause, 1.0)127 self.assertRaises(TypeError, self.solver.add_clause, object())128 self.assertRaises(TypeError, self.solver.add_clause, ['a'])129 self.assertRaises(130 TypeError, self.solver.add_clause, [[1, 2], [3, None]])131 self.assertRaises(ValueError, self.solver.add_clause, [1, 0])132 def test_no_clauses(self):133 for n in range(7):134 self.assertEqual(self.solver.solve([]), (True, (None,)))135 def test_cnf1(self):136 for cl in clauses1:137 self.solver.add_clause(cl)...
test_action.py
Source:test_action.py
...17 @pytest.mark.parametrize('args, keyword', [({}, 'required'),18 ({'value': '//abc',19 'unsupported': 'x'}, 'expects arguments'),20 ({'value': '//abc', 'selector': 'x'}, 'expects selectors')])21 def test_wrong_args(self, args, keyword):22 with pytest.raises(ValueError) as e:23 new_action(self.name, args)24 assert keyword in str(e.value)25class TestInputAction:26 name = 'input'27 @pytest.mark.parametrize('args', [{'value': '//abc', 'text': 'abc'},28 {'value': '//abc', 'text': 'abc', 'selector': 'id'}])29 def test_correct_args(self, args):30 action = new_action(self.name, args)31 assert action.name == self.name32 expected = {'selector': 'xpath'}33 expected.update(args)34 assert action.args == expected35 @pytest.mark.parametrize('args, keyword', [({}, 'required'),36 ({'value': '//abc', 'text': 'abc',37 'unsupported': 'x'}, 'expects arguments'),38 ({'value': '//abc', 'text': 'abc', 'selector': 'x'}, 'expects selectors')])39 def test_wrong_args(self, args, keyword):40 with pytest.raises(ValueError) as e:41 new_action(self.name, args)42 assert keyword in str(e.value)43class TestSwitchWindow:44 name = 'switch_window'45 @pytest.mark.parametrize('args', ['1',46 {'index': 1},47 {'index': '1'}])48 def test_correct_args(self, args):49 action = new_action(self.name, args)50 assert action.name == self.name51 if isinstance(args, str):52 args = {'index': args}53 assert action.args == args54 @pytest.mark.parametrize('args', ['', 'a',55 {'index': ''},56 {'index': 'a'}])57 def test_wrong_args(self, args):58 with pytest.raises(ValueError) as e:59 a = new_action(self.name, args)60 print(a)61 print(e.value)...
test_MultiGenotype.py
Source:test_MultiGenotype.py
...5def test_2_genotypes():6 assert str(MultiGenotype(G('Aa'), G('cc'))) == 'Aacc'7def test_3_genotypes():8 assert str(MultiGenotype(G('kK'), G('FF'), G('Rr'))) == 'kKFFRr'9def test_wrong_args():10 with pytest.raises(ValueError):11 MultiGenotype(G('Cc'), 42)12def test_equality_1():13 assert MultiGenotype(G('ll'), G('Aa')) == MultiGenotype(G('ll'), G('Aa'))14def test_equality_2():15 assert MultiGenotype(G('bb'), G('cc')) != MultiGenotype(G('BB'), G('CC'))16def test_no_duplicate_genotype_classes():17 with pytest.raises(ValueError):18 MultiGenotype(G('Zz'), G('ZZ'))19def test_2_genotype_breeding_1():20 mg1 = MultiGenotype(G('Aa'), G('Bb'))21 mg2 = MultiGenotype(G('Aa'), G('Bb'))22 assert mg1.breed(mg2) == [23 'AABB', 'AABb', 'AaBB', 'AaBb',...
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!!