How to use read_none method in Robotframework

Best Python code snippet using robotframework

regular.py

Source:regular.py Github

copy

Full Screen

1import itertools2from utils.plotter import *3# --------------------------------------------------------------------4#5# automata based rules for languages6#7# --------------------------------------------------------------------8class Constraint:9 def __init__(self, transition, initial, final, closure):10 self.transition, self.initial, self.final = transition, initial, final11 self.closure = closure12 self.fda = None13 def states(self):14 return sorted(self.fda.transition.states)15 def compile(self):16 self.fda = FiniteAutomata(self.transition, self.initial, self.final)17 return self18 def __call__(self, state, character):19 assert self.fda20 buffers = list(self.fda.transition(Buffer(data=character, initial=State(state))))21 non_error_states = list(map(lambda b: not b.error, buffers))22 if sum(non_error_states):23 assert sum(non_error_states) == 124 index = non_error_states.index(True)25 return buffers[index].state()26 return ErrorState()27class ContainedRule(Constraint):28 def __init__(self, pattern, closure):29 self.pattern = pattern30 self.read_none = "read_none_0"31 states = {i + 1: "read_" + s + "_" + str(i + 1) for i, s in enumerate(self.pattern)}32 states[0] = self.read_none33 states[len(self.pattern)] = "read_" + self.pattern + "_" + str(len(self.pattern))34 transition = FADelta()35 for i, s in enumerate(self.pattern):36 transition.add(states[i], states[i + 1], s)37 for a in filter(lambda b: b != s, closure):38 transition.add(states[i], self.read_none, a)39 final = states[len(self.pattern)]40 for a in closure:41 transition.add(final, final, a)42 super().__init__(transition=transition, initial=states[0], final={final}, closure=closure)43class NotContainedRule(Constraint):44 def __init__(self, pattern, closure):45 self.pattern = pattern46 self.read_none = "read_none_0"47 states = {i + 1: "read_" + s + "_" + str(i + 1) for i, s in enumerate(self.pattern)}48 states[0] = self.read_none49 del states[len(self.pattern)]50 transition = FADelta()51 for i, s in enumerate(self.pattern):52 if i < len(self.pattern) - 1:53 transition.add(states[i], states[i + 1], s)54 for a in filter(lambda b: b != s, closure):55 transition.add(states[i], self.read_none, a)56 final = {states[i] for i in range(len(states))}57 super().__init__(transition=transition, initial=states[0], final=final, closure=closure)58class ParityRule(Constraint):59 def __init__(self, pattern, closure, is_even=True):60 self.pattern = pattern61 self.read_even = "read_even_" + self.pattern + "_0"62 self.read_odd = "read_odd_" + self.pattern + "_0"63 if is_even:64 self.read_any = "got_even_" + self.pattern + "_0"65 else:66 self.read_any = "got_odd_" + self.pattern + "_0"67 states = {i + 1: "read_even_" + s + "_" + str(i + 1) for i, s in enumerate(self.pattern)}68 states.update({i + 1 + len(self.pattern): "read_odd_" + s + "_" + str(i + 1)69 for i, s in enumerate(self.pattern)})70 states[0] = self.read_even71 states[len(self.pattern)] = self.read_odd72 states[2 * len(self.pattern)] = self.read_even73 transition = FADelta()74 for i, s in enumerate(self.pattern):75 transition.add(states[i], states[i + 1], s)76 for a in filter(lambda b: b != s, closure):77 transition.add(states[i], self.read_even, a)78 for i, s in enumerate(self.pattern):79 transition.add(states[i + len(self.pattern)], states[i + len(self.pattern) + 1], s)80 for a in filter(lambda b: b != s, closure):81 transition.add(states[i + len(self.pattern)], self.read_odd, a)82 if is_even:83 final = {self.read_even}84 else:85 final = {self.read_odd}86 super().__init__(transition=transition, initial=states[0], final=final, closure=closure)87class EvenRule(ParityRule):88 def __init__(self, **kwargs):89 super().__init__(**kwargs, is_even=True)90class OddRule(ParityRule):91 def __init__(self, **kwargs):92 super().__init__(**kwargs, is_even=False)93class OrderRule(Constraint):94 def __init__(self, before, after, closure):95 self.state_before = "read_in_" + "".join([s for s in before]) + "_0"96 self.state_after = "read_inr_" + "".join([s for s in after]) + "_0"97 final = {self.state_before, self.state_after}98 transition = FADelta()99 for s in before:100 transition.add(self.state_before, self.state_before, s)101 for s in after:102 transition.add(self.state_after, self.state_after, s)103 for s in after.difference(before):104 transition.add(self.state_before, self.state_after, s)105 super().__init__(transition=transition, initial=self.state_before, final=final, closure=closure)106# --------------------------------------------------------------------107#108# rules declaration109#110# --------------------------------------------------------------------111class RuleDefinition:112 def __init__(self, **kwargs):113 self.kwargs = kwargs114 def build(self, closure):115 return self._build(**self.kwargs, closure=closure)116 def _build(self, **kwargs):117 raise RuntimeError("_build not implemented")118class Even(RuleDefinition):119 def __init__(self, **kwargs):120 super().__init__(**kwargs)121 def _build(self, **kwargs):122 return EvenRule(**kwargs)123class Odd(RuleDefinition):124 def __init__(self, **kwargs):125 super().__init__(**kwargs)126 def _build(self, **kwargs):127 return OddRule(**kwargs)128class Contained(RuleDefinition):129 def __init__(self, **kwargs):130 super().__init__(**kwargs)131 def _build(self, **kwargs):132 return ContainedRule(**kwargs)133class NotContained(RuleDefinition):134 def __init__(self, **kwargs):135 super().__init__(**kwargs)136 def _build(self, **kwargs):137 return NotContainedRule(**kwargs)138class Order(RuleDefinition):139 def __init__(self, **kwargs):140 super().__init__(**kwargs)141 def _build(self, **kwargs):142 return OrderRule(**kwargs)143# --------------------------------------------------------------------144#145# regular languages definition146#147# --------------------------------------------------------------------148class RegularLanguage:149 def __init__(self, alphabet, definition):150 self.alphabet, self.definition = list(alphabet), definition151 self._sanity()152 closure = definition["closure"]153 self.rules = [rule.build(closure).compile() for rule in definition["rules"]]154 states = [sorted(each.fda.transition.states) for each in self.rules]155 states_map, initial, final = {}, None, set()156 for i, each in enumerate(list(itertools.product(*states))):157 state = "z" + str(i)158 states_map[each] = state159 all_initial = all(map(lambda ini, s: s == ini,160 [r.fda.initial for r in self.rules], [e for e in each]))161 all_final = all(map(lambda fin, s: s in fin,162 [r.fda.final for r in self.rules], [e for e in each]))163 if all_initial:164 assert not initial165 initial = state166 if all_final:167 final.add(state)168 columns = ["states"] + ["P_" + str(i) for i in range(len(self.rules))] + \169 ["type"] + [a for a in self.alphabet]170 self.frame = pandas.DataFrame(columns=columns)171 for each in states_map:172 state = states_map[each]173 next_states = []174 for a in self.alphabet:175 next_tuple = tuple(self.rules[i](s, a) if a in self.rules[i].fda.transition.alphabet else s176 for i, s in enumerate(each))177 if next_tuple in states_map:178 next_states.append(states_map[next_tuple])179 else:180 next_states.append("err")181 state_type = FiniteAutomata.NodeType.NONE182 if state == initial and state in final:183 state_type = FiniteAutomata.NodeType.INITIAL + "/" + FiniteAutomata.NodeType.FINAL184 elif state == initial:185 state_type = FiniteAutomata.NodeType.INITIAL186 elif state in final:187 state_type = FiniteAutomata.NodeType.FINAL188 row = [state] + [c for c in each] + [state_type] + next_states189 self.frame = pandas.concat([self.frame, pandas.DataFrame([row], columns=columns)])190 self.fda = FiniteAutomataBuilder. \191 get_finite_automata_from_frame(self.frame[["states", "type"] + self.alphabet]).strip_redundant()192 def _sanity(self):193 assert "rules" in self.definition194 assert "closure" in self.definition...

Full Screen

Full Screen

test_scalar_assignment.py

Source:test_scalar_assignment.py Github

copy

Full Screen

...111 assert global_used_present == True112 assert global_unused_present == False113def test_build_read_none_only_builds_read_none_functions():114 test_file = Path(os.getcwd()) / "read_none_write_only_reads_memory_test.bc"115 essence_build_read_none(test_file, "output/read_none", False)116 assert os.path.isfile("output/read_none/read_none.cpp") == True117 assert os.path.isfile("output/read_none/write_only.cpp") == False118 assert os.path.isfile("output/read_none/reads_memory.cpp") == False119def test_build_read_none_only_builds_write_only_functions():120 test_file = Path(os.getcwd()) / "read_none_write_only_reads_memory_test.bc"121 essence_build_write_only(test_file, "output/write_only", False)122 assert os.path.isfile("output/write_only/read_none.cpp") == False123 assert os.path.isfile("output/write_only/write_only.cpp") == True124 assert os.path.isfile("output/write_only/reads_memory.cpp") == False125def test_cyclic_with_single_struct():126 program_output = call_handsanitizer("cyclic_with_single_struct")127 output_json = json.loads(program_output)128 print(json.dumps(output_json, indent=4))129 assert output_json["output"] == 1

Full Screen

Full Screen

pic.py

Source:pic.py Github

copy

Full Screen

1"""2pyxt.components - Various components needed for PyXT.3"""4# Standard library imports5# Six imports6from six.moves import range # pylint: disable=redefined-builtin7# PyXT imports8from pyxt.bus import Device9# Logging setup10import logging11log = logging.getLogger(__name__)12log.addHandler(logging.NullHandler())13# Classes14class ProgrammableInterruptController(Device):15 """ An IOComponent emulating an 8259 PIC controller. """16 EDGE_TRIGGERED = 017 LEVEL_TRIGGERED = 118 19 READ_NONE = 0x0020 READ_NONE_ALSO = 0x0121 READ_IR_REGISTER = 0x0222 READ_IS_REGISTER = 0x0323 OCW3_READ_REGISTER_MASK = 0x0324 25 def __init__(self, base, **kwargs):26 super(ProgrammableInterruptController, self).__init__(**kwargs)27 self.base = base28 29 # Configuration "registers".30 self.cascade = False31 self.mask = 0x0032 self.trigger_mode = self.EDGE_TRIGGERED33 self.priorities = [0, 1, 2, 3, 4, 5, 6, 7]34 self.vector_base = 0x0035 self.address_interval = 436 self.i8086_8088_mode = False37 self.auto_eoi = False38 self.slave_mode_address = 739 40 # ICWS (Initialization Commands Words) state machine, per the datasheet.41 # 0 indicates the idle state, 1-4 indicate what byte will be processed next.42 self.icws_state = 043 self.icw4_needed = False44 45 self.read_register = self.READ_NONE46 self.interrupt_request_register = 0x0047 self.interrupt_in_service_register = 0x0048 49 self.__interrupt_pending = False50 51 # Device interface.52 def get_ports_list(self):53 return [x for x in range(self.base, self.base + 2)]54 55 def io_read_byte(self, address):56 offset = address - self.base57 if offset == 1:58 return self.mask59 elif self.read_register == self.READ_IR_REGISTER:60 return self.interrupt_request_register61 elif self.read_register == self.READ_IS_REGISTER:62 return self.interrupt_in_service_register63 else:64 return 0x0065 66 def io_write_byte(self, address, value):67 offset = address - self.base68 if offset == 0 and value & 0x10 == 0x10:69 self.start_initialization_sequence()70 71 if self.icws_state > 0:72 self.process_icws_byte(value)73 else:74 if offset == 1:75 self.mask = value76 else:77 if value & 0x08 == 0x08:78 self.process_ocw3_byte(value)79 else:80 self.process_ocw2_byte(value)81 82 # Local functions.83 def start_initialization_sequence(self):84 """ Kick off the 8259 initialization sequence. """85 self.trigger_mode = self.EDGE_TRIGGERED86 self.mask = 0x0087 self.priorities[7] = 788 self.slave_mode_address = 789 # TODO: Clear special mask mode?90 # TODO: Set status read to IRR?91 self.icws_state = 192 self.icw4_needed = False93 94 def process_icws_byte(self, value):95 """ Run a byte through the initialization state machine. """96 if self.icws_state == 1:97 self.icw4_needed = value & 0x01 == 0x0198 self.cascade = not (value & 0x02 == 0x02)99 self.address_interval = 4 if value & 0x04 == 0x04 else 8100 self.trigger_mode = self.LEVEL_TRIGGERED if value & 0x04 == 0x04 else self.EDGE_TRIGGERED101 # TODO: No support for full MCS-80/8085 vector addresses.102 103 if not self.icw4_needed:104 self.i8086_8088_mode = False105 self.auto_eoi = False106 107 self.icws_state = 2108 109 elif self.icws_state == 2:110 self.vector_base = value & 0xF8111 # TODO: No support for full MCS-80/8085 vector addresses.112 113 if self.cascade:114 self.icws_state = 3115 elif self.icw4_needed:116 self.icws_state = 4117 else:118 self.icws_state = 0119 120 elif self.icws_state == 3:121 # TODO: Currently no support for cascade mode or slave 8259's.122 if self.icw4_needed:123 self.icws_state = 4124 else:125 self.icws_state = 0126 127 elif self.icws_state == 4:128 self.i8086_8088_mode = value & 0x01 == 0x01129 self.auto_eoi = value & 0x02 == 0x02130 # TODO: Currently no support for buffered mode.131 # TODO: No support for "special fully nested mode".132 self.icws_state = 0133 134 def process_ocw2_byte(self, value):135 command = (value & 0xE0) >> 5136 interrupt = value & 0x07137 # print("command = %r, interrupt = %r" % (command, interrupt))138 139 def process_ocw3_byte(self, value):140 self.read_register = value & self.OCW3_READ_REGISTER_MASK141 142 def interrupt_request(self, irq):143 """ Called when an interrupt is requested from a device. """144 irq_mask = 0x01 << irq145 146 # If the IRQ is masked, ignore the request.147 if irq_mask & self.mask == irq_mask:148 return149 150 # Log that the interrupt is pending service.151 self.interrupt_request_register |= irq_mask152 153 # Signal the CPU that an interrupt has occured.154 self.set_interrupt_signal(True)155 156 def interrupt_acknowledge(self):157 """ Acknowledges the highest priority interrupt and returns the vector number. """158 # TODO: Proper priority handling.159 for irq in range(8):160 irq_mask = 0x01 << irq161 if irq_mask & self.interrupt_request_register == irq_mask:162 self.interrupt_request_register &= ~irq_mask163 self.interrupt_in_service_register |= irq_mask164 165 # If this was the only bit set, clear the interrupt line.166 if self.interrupt_request_register == 0x00 and self.bus:167 self.set_interrupt_signal(False)168 169 return self.vector_base + irq170 171 raise RuntimeError("interrupt_acknowledge() called with no pending interrupts!")172 173 def interrupt_pending(self):174 """ Returns the state of the INT line to the CPU for unit testing. """175 return self.__interrupt_pending176 177 def set_interrupt_signal(self, value):178 """ Set the state of the INT line to the CPU. """179 self.__interrupt_pending = value180 if self.bus and self.bus.cpu:181 self.bus.cpu.interrupt_signaled = value...

Full Screen

Full Screen

pyasm.py

Source:pyasm.py Github

copy

Full Screen

...51 return read_float(l)52 elif l.split()[0] == 'code':53 return read_code(f)54 elif l.split()[0] == 'none':55 return read_none(l)56 elif l.split()[0] == 'list':57 return read_list(f, parse_int(l.split()[1]))58 elif l.split()[0] == 'tuple':59 return tuple(read_list(f, parse_int(l.split()[1])))60 elif l.split()[0] == 'dict':61 return read_dict(f, parse_int(l.split()[1]))62 elif l.split()[0] == 'include':63 return parse_file(read_string(l) + '.pyasm')64def read_dict(f, count):65 r = {}66 for i in range(count):67 r[read_object(f)] = read_object(f)68 return r69def is_number(s):70 if s >= '0' and s <= '9':71 return True72 return False73def read_list(f, count):74 r = [None] * count75 index = 076 l = read_line(f)77 while l != 'end':78 if is_number(l.split()[0][0]) and l.split()[1] != '*':79 index = parse_int(l.split()[0])80 l = l.split(' ', 1)[1]81 r[index] = read_object(f, l)82 index += 183 elif is_number(l.split()[0][0]):84 count = parse_int(l.split()[0])85 l = l.split(' ', 2)[2]86 obj = read_object(f, l)87 for i in range(count):88 r[index] = obj89 index += 190 else:91 r[index] = read_object(f, l)92 index += 193 l = read_line(f)94 return r95def read_string(l):96 s = l.split('"', 1)[1]97 end_index = 098 escaped = False99 for i in range(len(s)):100 if escaped:101 continue102 if s[i] == '"':103 end_index = i104 break105 if s[i] == '\\':106 escaped = True107 return s[:i].decode("string-escape")108def read_int(l):109 return parse_int(l.split()[1])110def read_float(l):111 return float(l.split()[1])112def read_none(l):113 return None114def process_labels(f):115 labels = {}116 l = read_line(f).split('#')[0].strip()117 pos = 0118 while l != 'end':119 count = 1120 instruction_len = 1121 if l[-1] == ':': # check for a : to see if the current line is a label122 labels[l[:-1]] = pos123 count = 0 # not an instruction124 elif len(l.split()) > 2:125 if l.split()[1] == '*':126 count = parse_int(l.split()[0])...

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