Best Python code snippet using autotest_python
__init__.py
Source: __init__.py
...90 # because we don't know what type they return91 _kwargs = {}92 elif not _callable(spec):93 Klass = NonCallableMagicMock94 elif is_type and instance and not _instance_callable(spec):95 Klass = NonCallableMagicMock96 _name = _kwargs.pop('name', _name)97 _new_name = _name98 if _parent is None:99 # for a top level object no _new_name should be set100 _new_name = ''101 mock = Klass(parent=_parent, _new_parent=_parent, _new_name=_new_name,102 name=_name, **_kwargs)103 if isinstance(spec, FunctionTypes):104 # should only happen at the top level because we don't105 # recurse for functions106 mock = _set_signature(mock, spec)107 else:108 _check_signature(spec, mock, is_type, instance)...
992.py
Source: 992.py
1#!/usr/bin/env python32# 2014-10-21T18:12+08:003"""4Benchmark test for list & deque in Python.5This program is inspired by a question on zhihu.com: 6http://www.zhihu.com/question/260914677Some more useful information:8http://stackoverflow.com/questions/23487307/python-deque-vs-list-performance-comparison9http://stackoverflow.com/questions/1296511/efficiency-of-using-a-python-list-as-a-queue10C++ benchmark test:11http://baptiste-wicht.com/posts/2012/12/cpp-benchmark-vector-list-deque.html12http://blog.davidecoppola.com/2014/05/20/cpp-benchmarks-vector-vs-list-vs-deque/13http://stackoverflow.com/questions/1436020/c-stl-containers-whats-the-difference-between-deque-and-list14"""15import collections16#import inspect17import random18import timeit19#import types20loops = random.randint(10000, 100000)21rng = range(loops)22def benchmark_list_pop_front():23 s = list(rng)24 for i in rng:25 s.pop(0)26def benchmark_list_pop_back():27 s = list(rng)28 for i in rng:29 s.pop(-1)30def benchmark_deque_pop_front():31 q = collections.deque(rng)32 for i in rng:33 q.popleft()34def benchmark_deque_pop_back():35 q = collections.deque(rng)36 for i in rng:37 q.pop()38def benchmark_list_push_front():39 s = []40 for i in rng:41 s.insert(0, None)42def benchmark_list_push_back():43 s = []44 for i in rng:45 s.append(None)46def benchmark_deque_push_front():47 q = collections.deque()48 for i in rng:49 q.appendleft(None)50def benchmark_deque_push_back():51 q = collections.deque()52 for i in rng:53 q.append(None)54if __name__ == '__main__':55 print(loops, 'loops')56 57 for i in dir():58 item = locals()[i]59 # Several ways to check whether an object is callable or not.60 # 0. unittest.mock defines two internal function: _callable, _instance_callable61 # 1. if isinstance(item, collections.Callable) and i.startswith('benchmark'):62 # 2. if isinstance(item, types.FunctionType) and i.startswith('benchmark'):63 # 3. if inspect.isfunction(item) and i.startswith('benchmark'):64 # 4. 65 if hasattr(item, '__call__') and i.startswith('benchmark'):66 print('{}:'.format(i),67 timeit.timeit('{}()'.format(i),68 setup = 'from __main__ import {}'.format(i),69 number = 1)...
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!!