How to use set_finish method in autotest

Best Python code snippet using autotest_python

hypothesis.py

Source:hypothesis.py Github

copy

Full Screen

...28 elif isinstance(action, ReduceAction):29 assert self.frontier_field.cardinality in ('optional', 'multiple'), 'Reduce action can only be ' \30 'applied on field with multiple ' \31 'cardinality'32 self.frontier_field.set_finish()33 self.update_frontier_info()34 else:35 raise ValueError('Invalid action [%s] on field [%s]' % (action, self.frontier_field))36 else: # fill in a primitive field37 if isinstance(action, GenTokenAction):38 # only field of type string requires termination signal </primitive>39 end_primitive = False40 if self.frontier_field.type.name == 'string':41 if action.is_stop_signal():42 self.frontier_field.add_value(' '.join(self._value_buffer))43 self._value_buffer = []44 end_primitive = True45 else:46 self._value_buffer.append(action.token)47 else:48 self.frontier_field.add_value(action.token)49 end_primitive = True50 if end_primitive and self.frontier_field.cardinality in ('single', 'optional'):51 self.frontier_field.set_finish()52 self.update_frontier_info()53 elif isinstance(action, ReduceAction):54 assert self.frontier_field.cardinality in ('optional', 'multiple'), 'Reduce action can only be ' \55 'applied on field with multiple ' \56 'cardinality'57 self.frontier_field.set_finish()58 self.update_frontier_info()59 else:60 raise ValueError('Can only invoke GenToken or Reduce actions on primitive fields')61 self.t += 162 self.actions.append(action)63 #add by gsh64 65 def apply_lay_action(self, action):66 if self.tree is None:67 assert isinstance(action, ApplyRuleAction), 'Invalid action [%s], only ApplyRule action is valid ' \68 'at the beginning of decoding'69 self.tree = AbstractSyntaxTree(action.production)70 self.update_frontier_info()71 elif self.frontier_node:72 if isinstance(self.frontier_field.type, ASDLCompositeType):73 if isinstance(action, ApplyRuleAction):74 field_value = AbstractSyntaxTree(action.production)75 field_value.created_time = self.t76 self.frontier_field.add_value(field_value)77 self.update_frontier_info()78 elif isinstance(action, ReduceAction):79 assert self.frontier_field.cardinality in ('optional', 'multiple'), 'Reduce action can only be ' \80 'applied on field with multiple ' \81 'cardinality'82 self.frontier_field.set_finish()83 self.update_frontier_info()84 else:85 raise ValueError('Invalid action [%s] on field [%s]' % (action, self.frontier_field))86 else: # fill in a primitive field87 if self.frontier_field.cardinality =='single':88 self.frontier_field.add_value('NULL')89 self.frontier_field.set_finish()90 self.update_frontier_info()91 elif isinstance(action, ReduceAction):92 assert self.frontier_field.cardinality in ('optional', 'multiple'), 'Reduce action can only be ' \93 'applied on field with multiple ' \94 'cardinality'95 self.frontier_field.set_finish()96 self.update_frontier_info()97 else:98 raise ValueError('Can only invoke GenToken or Reduce actions on primitive fields')99 self.t += 1100 self.actions.append(action) 101 def update_frontier_info(self):102 def _find_frontier_node_and_field(tree_node):103 if tree_node:104 for field in tree_node.fields:105 # if it's an intermediate node, check its children106 if isinstance(field.type, ASDLCompositeType) and field.value:107 if field.cardinality in ('single', 'optional'): iter_values = [field.value]108 else: iter_values = field.value109 for child_node in iter_values:...

Full Screen

Full Screen

DynamicProgrammingBasicProperties.py

Source:DynamicProgrammingBasicProperties.py Github

copy

Full Screen

...23 def test_solve_incorrect_finish(self):24 vertex = Vertex()25 g = DynamicProgramming([], [])26 with self.assertRaises(ValueError):27 g.set_finish(vertex)28 def test_solve_simple(self):29 """Solve simple problem30 start --1--> finish31 Right answer is 132 """33 start = Vertex('start')34 finish = Vertex('finish')35 for S in semirings:36 e = Edge(start, finish, S.unity())37 g = DynamicProgramming([start, finish], [e])38 g.set_start(start)39 g.set_finish(finish)40 self.assertEqual(g.solve(S), S.unity())41 def test_solve_square(self):42 """Solve problem with square43 start ---1--> A44 | |45 1 146 | |47 V V48 B ---1--> finish49 Right answer is (1*1 + 1*1)50 """51 start = Vertex('start')52 finish = Vertex('finish')53 a = Vertex('a')54 b = Vertex('b')55 for S in semirings:56 start_a = Edge(start, a, S.unity())57 start_b = Edge(start, b, S.unity())58 a_finish = Edge(a, finish, S.unity())59 b_finish = Edge(b, finish, S.unity())60 g = DynamicProgramming([start, a, b, finish], [start_a, start_b,61 a_finish, b_finish])62 g.set_start(start)63 g.set_finish(finish)64 self.assertEqual(g.solve(S), S.unity()+S.unity())65 def test_solve_big_square(self):66 """Find length of the shortest path (min,+)67 start -5-> A ---1----> B --3--> C68 | |69 1 970 | |71 V V72 x --5--> y --2--> z --1--> finish73 Right answer is 974 """75 start = Vertex('start')76 finish = Vertex('finish')77 a = Vertex('a')78 b = Vertex('b')79 c = Vertex('c')80 x = Vertex('x')81 y = Vertex('y')82 z = Vertex('z')83 start_a = Edge(start, a, SemiringMinPlusElement(5))84 a_b = Edge(a, b, SemiringMinPlusElement(1))85 b_c = Edge(b, c, SemiringMinPlusElement(3))86 c_finish = Edge(c, finish, SemiringMinPlusElement(9))87 start_x = Edge(start, x, SemiringMinPlusElement(1))88 x_y = Edge(x, y, SemiringMinPlusElement(5))89 y_z = Edge(y, z, SemiringMinPlusElement(2))90 z_finish = Edge(z, finish, SemiringMinPlusElement(1))91 g = DynamicProgramming([start, finish, a, b, c, x, y, z],92 [start_a, a_b, b_c, c_finish,93 start_x, x_y, y_z, z_finish])94 g.set_start(start)95 g.set_finish(finish)96 self.assertEqual(g.solve(SemiringMinPlusElement),97 SemiringMinPlusElement(9))98 def test_solve_crossed_square(self):99 """Find length of the shortest path (min,+)100 start -5-> A ---1----> B --3--> C101 | | |102 1 0 9103 | | |104 V V V105 x --5--> y --2--> z --1--> finish106 Right answer is 8107 """108 start = Vertex('start')109 finish = Vertex('finish')110 a = Vertex('a')111 b = Vertex('b')112 c = Vertex('c')113 x = Vertex('x')114 y = Vertex('y')115 z = Vertex('z')116 start_a = Edge(start, a, SemiringMinPlusElement(5))117 a_b = Edge(a, b, SemiringMinPlusElement(1))118 b_c = Edge(b, c, SemiringMinPlusElement(3))119 c_finish = Edge(c, finish, SemiringMinPlusElement(9))120 start_x = Edge(start, x, SemiringMinPlusElement(1))121 x_y = Edge(x, y, SemiringMinPlusElement(5))122 y_z = Edge(y, z, SemiringMinPlusElement(2))123 z_finish = Edge(z, finish, SemiringMinPlusElement(1))124 a_y = Edge(a, y, SemiringMinPlusElement(0))125 g = DynamicProgramming([start, finish, a, b, c, x, y, z],126 [start_a, a_b, b_c, c_finish,127 start_x, x_y, y_z, z_finish,128 a_y])129 g.set_start(start)130 g.set_finish(finish)131 self.assertEqual(g.solve(SemiringMinPlusElement),132 SemiringMinPlusElement(8))133if __name__ == '__main__':...

Full Screen

Full Screen

log_handler.py

Source:log_handler.py Github

copy

Full Screen

...19 ret2 = os.system('cat %s | grep "\[.*@.*\][\$\#]" >> %s.his' % (filename, filename))20 ret3 = os.system('cat %s | grep "EndTime" >> %s.his' % (filename, filename))21 if (ret1 + ret2 + ret3) == 0:22 print 'Handler %s ok.' % filename23def set_finish(id):24 logs = Logs.objects.filter(id=id, finish=0)25 if logs:26 structtime_start = time.localtime()27 timestamp_end = int(time.mktime(structtime_start))28 log = logs[0]29 log.finish = 130 log.end_time = timestamp_end31 log.save()32def kill_pid(pid):33 try:34 os.kill(pid, 9)35 except OSError:36 pass37def pid_exist(pid):38 pid_dir = "/proc/%s" % pid39 if os.path.isdir(pid_dir):40 return True41 else:42 return False43def del_pid(pid_id):44 pid = Pid.objects.filter(id=pid_id)45 if pid:46 pid[0].delete()47def get_pids():48 pids = []49 pids_obj = Pid.objects.all()50 for pid_obj in pids_obj:51 pids.append((pid_obj.id, pid_obj.ppid, pid_obj.cpid, pid_obj.logid, pid_obj.start_time))52 return pids53def run():54 for pid_id, ppid, cpid, logid, start_time in get_pids():55 if pid_exist(cpid):56 if pid_exist(ppid):57 structtime_start = time.localtime()58 timestamp_end = int(time.mktime(structtime_start))59 if timestamp_end - start_time > 7200:60 kill_pid(ppid)61 kill_pid(cpid)62 del_pid(pid_id)63 set_finish(logid)64 log_hanler(logid)65 else:66 kill_pid(cpid)67 del_pid(pid_id)68 set_finish(logid)69 log_hanler(logid)70 else:71 del_pid(pid_id)72 set_finish(logid)73 log_hanler(logid)74if __name__ == '__main__':75 while True:76 run()...

Full Screen

Full Screen

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 autotest 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