Best Python code snippet using yandex-tank
_translation_map.py
Source: _translation_map.py
...78 """Update bindings. Mappings name->source are always added, but may be overridden by the user."""79 source_to_source = {source: source for source in self.sources}80 self._name_to_source: NameToSourceDict = {**source_to_source, **value}81 @property82 def default_fmt(self) -> Optional[Format]:83 """Return the format specification to use instead of `fmt` for fallback translation."""84 return self._default_fmt # pragma: no cover85 @default_fmt.setter86 def default_fmt(self, value: Optional[FormatType]) -> None:87 self._default_fmt = None if value is None else Format.parse(value)88 @property89 def fmt(self) -> Optional[Format]:90 """Return the translation format."""91 return self._fmt # pragma: no cover92 @fmt.setter93 def fmt(self, value: Optional[FormatType]) -> None:94 self._fmt = None if value is None else Format.parse(value)95 @property96 def reverse_mode(self) -> bool:97 """Return reversed mode status flag.98 If set, the mappings returned by :meth:`apply` (and therefore also ``__getitem__`` are reversed.99 Returns:100 Reversal status flag....
myutil.py
Source: myutil.py
1from datetime import datetime2from datetime import *3DEFAULT_FMT = '%Y-%m-%d %H:%M:%S'4def from_unix_time(timestamp, FMT=DEFAULT_FMT):5 int_time = timestamp6 if type(int_time) == str:7 int_time = int(int_time)8 return datetime.fromtimestamp(int_time).strftime(DEFAULT_FMT)9def format_datetime(dt, FMT=DEFAULT_FMT):10 return dt.strftime(FMT)11def now(FMT=DEFAULT_FMT):12 return format_datetime(datetime.now())13def get_interval(tdelta, mode='m'):14 if mode == 'm':15 return tdelta.seconds / 6016 elif mode == 's':17 return tdelta.seconds18 elif mode == 'h':19 return tdelta.seconds / 360020 elif mode == 'd':21 return tdelta.days22 else:23 return tdelta.microseconds24def time_diff(t1, t2, FMT=DEFAULT_FMT, mode='s'):25 tdelta = datetime.strptime(t2, FMT) - datetime.strptime(t1, FMT)26 return get_interval(tdelta, mode)27# unix timestamp28def after_time(t, interval, FMT=DEFAULT_FMT, mode='s'):29 t1 = datetime.strptime(t, FMT)30 if mode == 's':31 delta = timedelta(seconds=interval)32 elif mode == 'h':33 delta = timedelta(hours=interval)34 elif mode == 'm':35 delta = timedelta(minutes=interval)36 elif mode == 'd':37 delta = timedelta(days=interval)38 t2 = t1 + delta39 40 return format_datetime(t2, FMT)41def time_interval(dt1, dt2, mode='s'):42 if dt1 < dt2:43 return get_interval(dt2 - dt1, mode)44 else:45 return 0 - get_interval(dt1 - dt2, mode)46def time_interval_unix(t1, t2, mode='s'):47 dt1 = datetime.fromtimestamp(t1)48 dt2 = datetime.fromtimestamp(t2)49 return time_interval(dt1, dt2)50def from_now_unix(unix_time, mode='s'):51 if type(unix_time) == str:52 unix_time = int(unix_time)53 return time_interval(datetime.now(), datetime.fromtimestamp(unix_time), mode)54if __name__ == '__main__':55 # print from_unix_time('1433398870')56 # print time_diff('2015-06-04T13:19:58Z', '2015-06-04T14:18:58Z', mode='m')57 # print from_now_unix('1433398870', 'm')...
Check out the latest blogs from LambdaTest on this topic:
The key to successful test automation is to focus on tasks that maximize the return on investment (ROI), ensuring that you are automating the right tests and automating them in the right way. This is where test automation strategies come into play.
Greetings folks! With the new year finally upon us, we’re excited to announce a collection of brand-new product updates. At LambdaTest, we strive to provide you with a comprehensive test orchestration and execution platform to ensure the ultimate web and mobile experience.
Entering the world of testers, one question started to formulate in my mind: “what is the reason that bugs happen?”.
“Test frequently and early.” If you’ve been following my testing agenda, you’re probably sick of hearing me repeat that. However, it is making sense that if your tests detect an issue soon after it occurs, it will be easier to resolve. This is one of the guiding concepts that makes continuous integration such an effective method. I’ve encountered several teams who have a lot of automated tests but don’t use them as part of a continuous integration approach. There are frequently various reasons why the team believes these tests cannot be used with continuous integration. Perhaps the tests take too long to run, or they are not dependable enough to provide correct results on their own, necessitating human interpretation.
The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.
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!!