How to use append_int method in hypothesis

Best Python code snippet using hypothesis

comp_vmemory.py

Source:comp_vmemory.py Github

copy

Full Screen

...27 # res = [self.physical_address(entry) for entry in self.cells if type(entry) == vmemory.PointerCell]28 # # print 'end reloc table', time.time()-b29 # return res30 def append_external_ref(self, name, label=None):31 oop = self.append_int(0xAAAA, label)32 self.ext_ref_table.append((name, oop))33 return oop34 def append_object_instance(self):35 self.append_int(pyutils.FRAME_TYPE_OBJECT)36 self.append_int(2 * bits.WSIZE)37 oop = self.append_external_ref('Object') # vt38 self.append_null() # delegate: end of chain of delegation39 return oop40 def append_symbol_instance(self, string):41 self.append_int(pyutils.FRAME_TYPE_OBJECT)42 self.append_int(1 * bits.WSIZE)43 if string == '':44 return self.append_null()45 oop = self.append_int(0xBBBB)46 self.symb_table[oop] = string47 return oop48 def append_string_instance(self, string):49 if string in self.string_table:50 return self.string_table[string]51 else:52 delegate = self.append_object_instance()53 self.append_int(pyutils.FRAME_TYPE_BVAR_OBJECT)54 self.append_int((3 * bits.WSIZE) + bits.string_block_size(string + "\0"))55 oop = self.append_external_ref('String')56 self.append_pointer_to(delegate) # delegate57 self.append_int(len(string))58 self.append_string(string)59 self.string_table[string] = oop60 return oop61 def append_sym_to_string_dict(self, pydict):62 pairs_oop = []63 for key, val in iter(sorted(pydict.items())):64 key_oop = self.append_string_instance(key)65 val_oop = self.append_symbol_instance(val)66 pairs_oop.append((key_oop, val_oop))67 return self.append_dict_with_pairs(pairs_oop)68 def append_dict_prologue(self, size, frame_oop):69 delegate = self.append_object_instance()70 self.append_int(pyutils.FRAME_TYPE_DVAR_OBJECT)71 self.append_int(4 * bits.WSIZE)72 oop = self.append_external_ref('Dictionary') # vt73 self.append_pointer_to(delegate) # delegate74 self.append_int(size) # dict length75 if frame_oop is None:76 self.append_null()77 else:78 self.append_pointer_to(frame_oop)79 return oop80 def append_empty_list(self):81 delegate = self.append_object_instance()82 self.append_int(pyutils.FRAME_TYPE_LIST_OBJECT)83 self.append_int(4 * bits.WSIZE)84 oop = self.append_external_ref('List') # vt85 self.append_pointer_to(delegate) # delegate86 self.append_int(0) # len87 self.append_null() # frame88 return oop89 # used internally to create class fields list, etc.90 def append_list_of_strings(self, lst):91 oops_elements = [self.append_string_instance(string) for string in lst]92 delegate = self.append_object_instance()93 if len(lst) > 0:94 self.append_int(pyutils.FRAME_TYPE_ELEMENTS)95 self.append_int(len(lst) * bits.WSIZE)96 oops = []97 for oop_element in oops_elements: # .. elements98 oops.append(self.append_pointer_to(oop_element))99 self.append_int(pyutils.FRAME_TYPE_LIST_OBJECT)100 self.append_int(4 * bits.WSIZE)101 oop = self.append_external_ref('List') # vt102 self.append_pointer_to(delegate) # delegate103 self.append_int(len(lst)) # len104 if len(lst) > 0:105 self.append_pointer_to(oops[0])106 else:107 self.append_null()108 return oop109 def append_list_of_symbols(self, lst):110 oops_elements = [self.append_symbol_instance(string) for string in lst]111 delegate = self.append_object_instance()112 if len(lst) > 0:113 self.append_int(pyutils.FRAME_TYPE_ELEMENTS)114 self.append_int(len(lst) * bits.WSIZE)115 oops = []116 for oop_element in oops_elements: # .. elements117 oops.append(self.append_pointer_to(oop_element))118 self.append_int(pyutils.FRAME_TYPE_LIST_OBJECT)119 self.append_int(4 * bits.WSIZE)120 oop = self.append_external_ref('List') # vt121 self.append_pointer_to(delegate) # delegate122 self.append_int(len(lst)) # len123 if len(lst) > 0:124 self.append_pointer_to(oops[0])125 else:126 self.append_null()127 return oop128 # used internally to create class fields list, etc.129 def append_list_of_ints(self, lst):130 delegate = self.append_object_instance()131 if len(lst) > 0:132 self.append_int(pyutils.FRAME_TYPE_ELEMENTS)133 self.append_int(len(lst) * bits.WSIZE)134 oops = []135 for oop_element in lst: # .. elements136 oops.append(self.append_tagged_int(oop_element))137 self.append_int(pyutils.FRAME_TYPE_LIST_OBJECT)138 self.append_int(4 * bits.WSIZE)139 oop = self.append_external_ref('List') # vt140 self.append_pointer_to(delegate) # delegate141 self.append_int(len(lst)) # len142 if len(lst) > 0:143 self.append_pointer_to(oops[0])144 else:145 self.append_null()146 return oop147 def append_list_of_oops_for_labels(self, lst):148 delegate = self.append_object_instance()149 if len(lst) > 0:150 self.append_int(pyutils.FRAME_TYPE_ELEMENTS)151 self.append_int(len(lst) * bits.WSIZE)152 oops = []153 for label in lst: # .. elements154 oops.append(self.append_label_ref(label))155 self.append_int(pyutils.FRAME_TYPE_LIST_OBJECT)156 self.append_int(4 * bits.WSIZE)157 oop = self.append_external_ref('List') # vt158 self.append_pointer_to(delegate) # delegate159 self.append_int(len(lst)) # len160 if len(lst) > 0:161 self.append_pointer_to(oops[0])162 else:163 self.append_null()...

Full Screen

Full Screen

TCPcom.py

Source:TCPcom.py Github

copy

Full Screen

...7def append_uint(data, value, len, mult=1):8 v = np.uint32(value * mult)9 for i in range(len):10 data.append((v >> (len - i - 1) * 8) & 0xff)11def append_int(data, value, len, mult=1):12 v = np.int32(value * mult)13 for i in range(len):14 data.append(np.uint8((v >> (len - i - 1) * 8) & 0xff))15# si il y a besoin d'ajouter des données à envoyer c'est ici qu'il faut le faire16# il faudra aussi modifier le matlab pour qu'il traite ces nouvelles données17def encode_data(data):18 encoded = bytearray()19 append_uint(encoded, data[0], 2)20 append_int(encoded, data[1], 2, 100)21 append_int(encoded, data[2], 2)22 append_uint(encoded, data[3], 2)23 append_uint(encoded, data[4], 2, 100)24 append_uint(encoded, data[5], 2, 100)25 append_uint(encoded, data[6], 2)26 append_uint(encoded, data[7], 2, 100)27 append_int(encoded, data[8], 2, 100)28 append_int(encoded, data[9], 2, 100)29 append_int(encoded, data[10], 2, 100)30 append_uint(encoded, data[11], 2)31 boo = 0x00 | np.uint8(data[12]) | np.uint8(data[13]) << 1 | np.uint8(data[14]) << 2 \32 | np.uint8(data[15]) << 3 | np.uint8(data[16]) << 4 | np.uint8(data[17]) << 5 | np.uint8(data[18]) << 6 \33 | np.uint8(data[19]) << 734 encoded.append(boo)35 boo = 0x00 | np.uint8(data[20]) | np.uint8(data[21]) << 1 | np.uint8(data[22]) << 2 \36 | np.uint8(data[23]) << 3 | np.uint8(data[24]) << 4 | np.uint8(data[25]) << 5 | np.uint8(data[26]) << 6 \37 | np.uint8(data[27]) << 738 encoded.append(boo)39 append_uint(encoded, data[28], 1)40 append_uint(encoded, data[29], 1)41 append_int(encoded, data[43], 2, 100)42 append_int(encoded, data[44], 2, 100)43 append_int(encoded, data[45], 2, 100)44 append_int(encoded, data[46], 2, 100)45 # ajouter ici46 # si valeur non signée : append_uint(encoded, <valeur>, taille, facteur (optionnel) )47 # si valeur signée : append_int(encoded, <valeur>, taille, facteur (optionnel) )48 return encoded49class TCPCOM:50 def __init__(self, IP, PORT):51 self.connected = False52 self.HOST = IP53 self.PORT = PORT54 self.client = None55 while not self.connect():56 time.sleep(1)57 # retourne les infos reçu (None si rien à été reçu)58 def read(self):59 try:60 msg = self.client.recv(4096)61 except socket.timeout as e:...

Full Screen

Full Screen

send.py

Source:send.py Github

copy

Full Screen

...7TCP_IP = '127.0.0.1'8TCP_PORT = 400009BUFFER_SIZE = 102410MESSAGE = "Hello, World!"11def append_int(arr, val):12 arr.append((val & 0xff))13 arr.append((val & 0xff00) >> 8)14 arr.append((val & 0xff0000) >> 16)15 arr.append((val & 0xff000000) >> 24)16def make_block(block_len):17 arr = bytearray(block_len)18 for i in range(0, block_len):19 arr[i] = 0x7d20 return arr21try:22 print "Sending write requests message to 127.0.0.1"23 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)24 s.connect((TCP_IP, TCP_PORT))25 arr = bytearray()26 device_id = u"C_DRIVE\0"27 device_id = device_id.encode('utf-16le')28 # mode = write29 append_int(arr, 2) 30 # offset = 031 append_int(arr, 0)32 # BLOCK_SIZE = 1638433 append_int(arr, 16384)34 # device_id_length35 append_int(arr, len(device_id))36 s.send(arr)37 s.send(device_id)38 s.send(make_block(16384))39 arr = bytearray()40 append_int(arr, 0xd0d0d0d0)41 s.send(arr)42 # padding43 s.send(make_block(200+32+4-4*5-len(device_id)))44 # Receive write repsonse45 print "Receiving write response..."46 ret = s.recv(4096)47 print ret48 for b in ret:49 print hex(ord(b))50 ## s.close()51 ####################################################52 ## s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)53 ## s.connect((TCP_IP, TCP_PORT))54 print "Sending read requests message to 127.0.0.1"55 arr = bytearray()56 device_id = u"C_DRIVE\0"57 device_id = device_id.encode('utf-16le')58 # mode = read 59 append_int(arr, 1) 60 # offset = 061 append_int(arr, 0)62 # BLOCK_SIZE = 1638463 append_int(arr, 16384)64 # device_id_length65 append_int(arr, len(device_id))66 s.send(arr)67 s.send(device_id)68 s.send(make_block(16384))69 arr = bytearray()70 append_int(arr, 0xd0d0d0d0)71 s.send(arr)72 73 # padding74 s.send(make_block(200+32+4-4*5-len(device_id)))75 # Receive write repsonse76 print "Receiving write response..."77 ret = s.recv(32767)78 print "RESPONSE_LENGTH=", len(ret)79 i = 080 for b in ret:81 i = i + 182 if (i % 20 == 0):83 print84 print hex(ord(b)), ' ',...

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