How to use _len method in yandex-tank

Best Python code snippet using yandex-tank

bitvec.py

Source:bitvec.py Github

copy

Full Screen

...9def _check_value(value):10 if type(value) != type(0) or not 0 <= value < 2:11 raise error, 'bitvec() items must have int value 0 or 1'12import math13def _compute_len(param):14 mant, l = math.frexp(float(param))15 bitmask = 1L << l16 if bitmask <= param:17 raise RuntimeError('(param, l) = %r' % ((param, l),))18 while l:19 bitmask = bitmask >> 120 if param & bitmask:21 break22 l = l - 123 return l24def _check_key(len, key):25 if type(key) != type(0):26 raise TypeError, 'sequence subscript not int'27 if key < 0:28 key = key + len29 if not 0 <= key < len:30 raise IndexError, 'list index out of range'31 return key32def _check_slice(len, i, j):33 #the type is ok, Python already checked that34 i, j = max(i, 0), min(len, j)35 if i > j:36 i = j37 return i, j38class BitVec:39 def __init__(self, *params):40 self._data = 0L41 self._len = 042 if not len(params):43 pass44 elif len(params) == 1:45 param, = params46 if type(param) == type([]):47 value = 0L48 bit_mask = 1L49 for item in param:50 # strict check51 #_check_value(item)52 if item:53 value = value | bit_mask54 bit_mask = bit_mask << 155 self._data = value56 self._len = len(param)57 elif type(param) == type(0L):58 if param < 0:59 raise error, 'bitvec() can\'t handle negative longs'60 self._data = param61 self._len = _compute_len(param)62 else:63 raise error, 'bitvec() requires array or long parameter'64 elif len(params) == 2:65 param, length = params66 if type(param) == type(0L):67 if param < 0:68 raise error, \69 'can\'t handle negative longs'70 self._data = param71 if type(length) != type(0):72 raise error, 'bitvec()\'s 2nd parameter must be int'73 computed_length = _compute_len(param)74 if computed_length > length:75 print 'warning: bitvec() value is longer than the length indicates, truncating value'76 self._data = self._data & \77 ((1L << length) - 1)78 self._len = length79 else:80 raise error, 'bitvec() requires array or long parameter'81 else:82 raise error, 'bitvec() requires 0 -- 2 parameter(s)'83 def append(self, item):84 #_check_value(item)85 #self[self._len:self._len] = [item]86 self[self._len:self._len] = \87 BitVec(long(not not item), 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 yandex-tank 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