How to use read_constraints method in avocado

Best Python code snippet using avocado_python

test_solver.py

Source: test_solver.py Github

copy

Full Screen

...12 constraints = {((0, 0), (2, 0)), ((0, 1), (1, 1)), ((1, 0), (2, 0))}13 solver = Solver([], [])14 solver.data = parameters15 solver.constraints = constraints16 solver.read_constraints()17 solver.compute_constraints()18 self.assertEqual(solver.constraints, constraints, "compute_constraints change constraints without secret "19 "constraint")20 def test_compute_constraints_new_constraint_with_more_than_one_value_for_one_parameter(self):21 """22 Test that, function shouldn't change constraints. It founds new constraint,23 but the constraint has one parameter with two values. This means that it isn't secreted constraint.24 """25 parameters = [3, 3, 3]26 constraints = {((0, 0), (1, 0)), ((0, 1), (1, 1)), ((1, 2), (2, 0))}27 solver = Solver([], [])28 solver.data = parameters29 solver.constraints = constraints30 solver.read_constraints()31 solver.compute_constraints()32 self.assertEqual(solver.constraints, constraints, "compute_constraints change constraints without secret "33 "constraint")34 def test_compute_constraints_detect_invalid_constraints(self):35 """36 Test that, function should raise an exception, if there is invalid_constraints37 """38 parameters = [3, 3, 3]39 constraints = {((0, 0),), ((0, 1),), ((0, 2),)}40 solver = Solver([], [])41 solver.data = parameters42 solver.constraints = constraints43 solver.read_constraints()44 self.assertRaises(ValueError, solver.compute_constraints)45 def test_compute_constraints_with_one_secrete_constraint(self):46 """47 Test that, function should find new constraint48 """49 parameters = [3, 3, 3, 3]50 constraints = {((0, 0), (2, 0)), ((0, 1), (1, 1), (2, 0)), ((0, 2), (3, 2))}51 solver = Solver([], [])52 solver.data = parameters53 solver.constraints = constraints54 solver.read_constraints()55 solver.compute_constraints()56 expectation = {((0, 0), (2, 0)), ((0, 1), (1, 1), (2, 0)), ((0, 2), (3, 2)),57 ((1, 1), (2, 0), (3, 2))}58 self.assertEqual(solver.constraints, expectation, "compute_constraints didn't find secret constraints")59 # Test for simplify_constraints function60 def test_simplify_constraints_constraints_without_simplification(self):61 """62 Test that, function do not delete important constraints63 """64 parameters = [3, 3, 3, 3]65 constraints = {((0, 0), (2, 0)), ((0, 1), (1, 1), (2, 0)), ((0, 2), (3, 2))}66 solver = Solver([], [])67 solver.data = parameters68 solver.constraints = constraints69 solver.read_constraints()70 solver.simplify_constraints()71 self.assertEqual(solver.constraints, constraints, "simplify_constraints deleted some important constraints")72 def test_simplify_constraints_constraints_with_simplification(self):73 """74 Test that, function do not delete important constraints75 """76 parameters = [3, 3, 3, 3]77 constraints = {((0, 0), (2, 0)), ((0, 1), (2, 0), (1, 1)),78 ((0, 2), (2, 0)), ((2, 0),)}79 solver = Solver([], [])80 solver.data = parameters81 solver.constraints = constraints82 solver.read_constraints()83 solver.simplify_constraints()84 expectation = {((2, 0),)}85 self.assertEqual(solver.constraints, expectation, "simplify_constraints deleted some important constraints")86 # Test of Minimum forbidden tuple algorithm87 def test_solver_without_secrete_constraints(self):88 """89 Test that, solver didn't change constraints if there isn't any secret constraint90 """91 parameters = [3, 3, 3]92 constraints = {((0, 0), (2, 0)), ((0, 1), (1, 1)), ((1, 0), (2, 0))}93 solver = Solver(parameters, constraints)94 self.assertEqual(solver.constraints, constraints, "solver change constraints without secret "95 "constraint")96 def test_solver_constraints_without_simplification(self):...

Full Screen

Full Screen

universes-smt.py

Source: universes-smt.py Github

copy

Full Screen

1#!/​usr/​bin/​python2import sys3def read_constraints(file):4 lines = file.readlines()5 nodes = set()6 edges = set()7 last = None8 for ln in lines:9 ln = ln.replace(';', '')10 parts = ln.split()11 if len(parts) == 3:12 last = parts[0]13 elif len(parts) == 2:14 parts = [last, parts[0], parts[1]]15 else:16 assert False17 18 st = parts[0].strip()19 en = parts[2].strip()20 nodes.add(st)21 nodes.add(en)22 edges.add((st,en,parts[1].strip()))23 return (nodes, edges)24def dump_smt(nodes, edges, out=sys.stdout):25 def name_of(n):26 return n.replace('.', '_')27 for n in nodes:28 out.write("(define %s::int)\n" % name_of(n))29 out.write("\n")30 for (st, en, op) in edges:31 out.write("(assert (%s %s %s))\n" % (op, name_of(st), name_of(en)))32 33 out.write("(exit)\n")34if __name__ == '__main__':35 (nodes, edges) = read_constraints(sys.stdin)...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Nov’22 Updates: Live With Automation Testing On OTT Streaming Devices, Test On Samsung Galaxy Z Fold4, Galaxy Z Flip4, & More

Hola Testers! Hope you all had a great Thanksgiving weekend! To make this time more memorable, we at LambdaTest have something to offer you as a token of appreciation.

Considering Agile Principles from a different angle

In addition to the four values, the Agile Manifesto contains twelve principles that are used as guides for all methodologies included under the Agile movement, such as XP, Scrum, and Kanban.

How To Choose The Best JavaScript Unit Testing Frameworks

JavaScript is one of the most widely used programming languages. This popularity invites a lot of JavaScript development and testing frameworks to ease the process of working with it. As a result, numerous JavaScript testing frameworks can be used to perform unit testing.

How To Write End-To-End Tests Using Cypress App Actions

When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.

[LambdaTest Spartans Panel Discussion]: What Changed For Testing & QA Community And What Lies Ahead

The rapid shift in the use of technology has impacted testing and quality assurance significantly, especially around the cloud adoption of agile development methodologies. With this, the increasing importance of quality and automation testing has risen enough to deliver quality work.

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful