Best Python code snippet using autotest_python
mock.py
Source: mock.py
...44 if isinstance(self._return_value, Mock):45 self._return_value.reset()46 47 48 def __get_return_value(self):49 if self._return_value is DEFAULT:50 self._return_value = Mock()51 return self._return_value52 53 def __set_return_value(self, value):54 self._return_value = value55 56 return_value = property(__get_return_value, __set_return_value)57 def __call__(self, *args, **kwargs):58 self.called = True59 self.call_count += 160 self.call_args = (args, kwargs)61 self.call_args_list.append((args, kwargs))62 ...
coraldb.py
Source: coraldb.py
...11 '''12 self.address: str = address13 self.port: int = port14 self.authkey: Optional[str] = None15 def __get_return_value(self, result: str) -> CoralDBResult:16 if result == "OK.":17 return CoralDBResult.OK18 elif result == "ERROR.":19 return CoralDBResult.ERROR20 elif result == "WRONG-KEY.":21 return CoralDBResult.WRONGKEY22 else:23 return CoralDBResult.OK24 25 def set(self, key: str, value: str) -> CoralDBResult:26 '''Sets the specified key-value pair.27 '''28 key = key.replace('"', '\\\"').replace('\n', '\\n')29 value = value.replace('"', '\\\"').replace('\n', '\\n')30 result = self.run_connection(f"SET {key} \"{value}\"").strip()31 return self.__get_return_value(result)32 33 def get(self, key: str) -> Tuple[CoralDBResult, str]:34 '''Gets the specified key. Returns a tuple with the result of the35 command in the first position and the eventual value in the second.36 '''37 key = key.replace('"', '\\\"').replace('\n', '\\n')38 result = self.run_connection(f"GET {key}").strip()39 value = ""40 if self.__get_return_value(result) == CoralDBResult.OK:41 value = result.strip()[1:-1].replace('\\\"', '"').replace('\\n', '\n')42 return [self.__get_return_value(result), value]43 44 def probe(self, key: str) -> Tuple[CoralDBResult, bool]:45 '''Probes the specified key. Returns a tuple with the result of the46 command in the first position and the eventual probe result in the second.47 '''48 key = key.replace('"', '\\\"').replace('\n', '\\n')49 result = self.run_connection(f"PROBE {key}").strip()50 return [self.__get_return_value(result), result == "FOUND."]51 52 def drop(self, key: str) -> CoralDBResult:53 '''Drops the specified key.54 '''55 key = key.replace('"', '\\\"').replace('\n', '\\n')56 result = self.run_connection(f"DROP {key}").strip()57 return self.__get_return_value(result)58 59 def ping(self) -> bool:60 '''Pings the database.61 '''62 result = self.run_connection("PING").strip()63 return self.__get_return_value(result)64 65 def checkpoint(self) -> bool:66 '''Forces a database checkpoint.67 '''68 result = self.run_connection("CHECKPOINT").strip()69 return self.__get_return_value(result)70 71 def setkey(self, key: str) -> bool:72 '''Sets a database password.73 '''74 result = self.run_connection(f"SETKEY {key}").strip()75 return self.__get_return_value(result)76 77 def key(self, key: str) -> None:78 '''Sets the password to use when interfacing with the database.79 '''80 self.authkey = key81 if self.authkey == "":82 self.authkey = None83 84 def delkey(self) -> None:85 '''Removes the database password.86 '''87 result = self.run_connection("DELKEY").strip()88 return self.__get_return_value(result)89 def run_connection(self, command: str) -> str:90 try:91 total_data = ""92 if self.authkey is not None:93 command = f"KEY {self.authkey} {command}"94 with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:95 s.connect((self.address, self.port))96 s.sendall(bytes(command + "\r\n", "utf-8"))97 while True:98 data = s.recv(1024)99 if not data:100 break101 total_data += data.decode("utf-8")102 if "\r\n" in total_data:...
method_cache_manager.py
Source: method_cache_manager.py
...14 def decorator(*args, **kwargs):15 key = self.__get_key(name, *args, **kwargs)16 if key in self.__cache:17 return self.__cache[key]18 result = self.__get_return_value(method(*args, **kwargs))19 self.__cache[key] = result20 return result21 return decorator22 def __get_return_value(self, value):23 if type(value) in self.__decorate_types:24 return MethodCacheManager(value, self.__decorate_types)25 if isinstance(value, (list, tuple)):26 return self.__decorate_collection_values(value)27 return value28 def __decorate_collection_values(self, collection):29 decorated_values = list(collection)30 for i in range(len(decorated_values)):31 if type(decorated_values[i]) in self.__decorate_types:32 decorated_values[i] = MethodCacheManager(decorated_values[i])33 return decorated_values if isinstance(collection, list) else tuple(decorated_values)34 @staticmethod35 def __get_key(method_name, *args, **kwargs):36 return f"{method_name} ({args},{kwargs})"
Check out the latest blogs from LambdaTest on this topic:
Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.
So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.
Did you know that according to Statista, the number of smartphone users will reach 18.22 billion by 2025? Let’s face it, digital transformation is skyrocketing and will continue to do so. This swamps the mobile app development market with various options and gives rise to the need for the best mobile app testing tools
As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????
The count of mobile users is on a steep rise. According to the research, by 2025, it is expected to reach 7.49 billion users worldwide. 70% of all US digital media time comes from mobile apps, and to your surprise, the average smartphone owner uses ten apps per day and 30 apps each month.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!