How to use __get_return_value method in autotest

Best Python code snippet using autotest_python

mock.py

Source:mock.py Github

copy

Full Screen

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

Full Screen

Full Screen

coraldb.py

Source:coraldb.py Github

copy

Full Screen

...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:...

Full Screen

Full Screen

method_cache_manager.py

Source:method_cache_manager.py Github

copy

Full Screen

...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})"

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