How to use _instance_callable method in autotest

Best Python code snippet using autotest_python

__init__.py

Source:__init__.py Github

copy

Full Screen

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

Full Screen

Full Screen

992.py

Source:992.py Github

copy

Full Screen

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

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