How to use __out_of_order method in hypothesis

Best Python code snippet using hypothesis

cache.py

Source:cache.py Github

copy

Full Screen

...127 held for all other indexes (and no other values have been modified),128 this fixes the heap so that the heap property holds everywhere."""129 while i > 0:130 parent = (i - 1) // 2131 if self.__out_of_order(parent, i):132 self.__swap(parent, i)133 i = parent134 else:135 break136 while True:137 children = [138 j for j in (2 * i + 1, 2 * i + 2)139 if j < len(self.data)140 ]141 if len(children) == 2:142 children.sort(key=lambda j: self.data[j].score)143 for j in children:144 if self.__out_of_order(i, j):145 self.__swap(i, j)146 i = j147 break148 else:149 break150 def __out_of_order(self, i, j):151 """Returns True if the indices i, j are in the wrong order.152 i must be the parent of j.153 """154 assert i == (j - 1) // 2155 return self.data[j].score < self.data[i].score156class LRUReusedCache(GenericCache):157 """The only concrete implementation of GenericCache we use outside of tests158 currently.159 Adopts a modified least-frequently used eviction policy: It evicts the key160 that has been used least recently, but it will always preferentially evict161 keys that have only ever been accessed once. Among keys that have been162 accessed more than once, it ignores the number of accesses.163 This retains most of the benefits of an LRU cache, but adds an element of164 scan-resistance to the process: If we end up scanning through a large...

Full Screen

Full Screen

main.py

Source:main.py Github

copy

Full Screen

1from typing import List2import time3from decouple import config4import pyshark5class Observer:6 def __init__(self, time_out, iface, ip_addr) -> None:7 self.__time_out: int = time_out8 self.__iface: str = iface9 self.__ip_addr: str = ip_addr10 self.__packet_loss: List = []11 self.__packet_success: List = []12 self.__tcp_dup_ack: List = []13 self.__tcp_per: List = []14 self.__tcp_ret: List = []15 self.__tcp_fast_ret: List = []16 self.__out_of_order: List = []17 self.__tcp_spu: List = []18 19 @property20 def runner(self) -> None:21 self.__packetـfinder22 self.__calculate_error_packets23 self.__print_calculations24 @property25 def __packetـfinder(self) -> None:26 self.capture = pyshark.LiveCapture(interface=self.__iface, only_summaries=True)27 print("starting !!!")28 start_time = time.time()29 for j, pkt in enumerate(self.capture):30 str_p = str(pkt)31 if self.__ip_addr in str_p:32 print(j, ": ", pkt)33 if (34 "TCP Dup ACK" in str_p35 or "TCP Previous" in str_p36 or "TCP Retransmission" in str_p37 or "TCP Fast Retransmission" in str_p38 or "Out-Of-Order" in str_p39 or "TCP Spurious Retransmission" in str_p40 ):41 self.__packet_loss.append(str_p)42 else:43 self.__packet_success.append(str_p)44 if time.time() - start_time > self.__time_out:45 capture.close()46 break47 48 @property49 def __calculate_error_packets(self) -> None:50 for pkt_loss in self.__packet_loss:51 if "TCP Dup ACK" in pkt_loss:52 self.__tcp_dup_ack.append(pkt_loss)53 elif "TCP Previous" in pkt_loss:54 self.__tcp_per.append(pkt_loss)55 elif "TCP Retransmission" in pkt_loss:56 self.__tcp_ret.append(pkt_loss)57 elif "TCP Fast Retransmission" in pkt_loss:58 self.__tcp_fast_ret.append(pkt_loss)59 elif "Out-Of-Order" in pkt_loss:60 self.__out_of_order.append(pkt_loss)61 elif "TCP Spurious Retransmission" in pkt_loss:62 self.__tcp_spu.append(pkt_loss)63 @property64 def __print_calculations(self) -> None:65 print("=" * 80)66 print(67 "Data transfer failure ratio = ",68 len(self.__packet_loss) / (len(self.__packet_loss) + len(self.__packet_success)) * 100,69 "%",70 )71 print(72 "Data transfer successful ratio = ",73 len(self.__packet_success) / (len(self.__packet_loss) + len(self.__packet_success)) * 100,74 "%",75 )76 print("=" * 80)77 print("TCP Dup ACK = ", len(self.__tcp_dup_ack) / len(self.__packet_loss) * 100, "%")78 print("TCP Previous = ", len(self.__tcp_per) / len(self.__packet_loss) * 100, "%")79 print("TCP Retransmission = ", len(self.__tcp_ret) / len(self.__packet_loss) * 100, "%")80 print("TCP Fast Retransmission = ", len(self.__tcp_fast_ret) / len(self.__packet_loss) * 100, "%")81 print("TCP Out-Of-Order = ", len(self.__out_of_order) / len(self.__packet_loss) * 100, "%")82 print("TCP Spurious Retransmission = ", len(self.__tcp_spu) / len(self.__packet_loss) * 100, "%")83if __name__ == "__main__":84 ob = Observer(config("LISTENING_TIME", cast=int), config("INTERFACE"), config("LISTENER"))...

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