How to use _read_lines method in yandex-tank

Best Python code snippet using yandex-tank

device.py

Source:device.py Github

copy

Full Screen

...74 if line == b'ch> ':75 line = bytearray()76 break77 return line78 def _read_lines(self) -> [str]:79 result = []80 while True:81 line = self._read_line()82 if line == b'':83 break84 result.append(line.decode('utf-8').strip())85 return result86 # marker [n] [on|off|{index}]87 # marker numbering starts from 188 # the index is the point what value the marker should display from 0 to 100 (101) points by default89 def set_marker(self, n: int, index):90 self._send_command('marker %d %s' % (n, index))91 self._read_lines()92 # trace {0|1|2|3|all} [logmag|phase|delay|smith|polar|linear|swr|real|imag|r|x|q|off] [src]93 # trace {0|1|2|3} {scale|refpos} {value}94 def set_trace(self, trace, trace_format, channel):95 self._send_command('trace %s %s %s' % (trace, trace_format, channel))96 # the device output buffer contains the command, and the next prompt97 self._read_lines()98 # pause doesn't return anything but the 'ch> ' prompt, but as there is a \n\r and that prompt in the buffer99 # it's important to read them both, so the next command doesn't get confused100 def pause(self):101 self._send_command('pause')102 self._read_lines()103 def resume(self):104 self._send_command('resume')105 self._read_lines()106 def get_frequencies(self):107 self._send_command('frequencies')108 return self._read_lines()109 def capture(self) -> PIL.Image:110 self._send_command("capture")111 b = self.serial.read(320 * 240 * 2)112 x = struct.unpack(">76800H", b)113 arr = np.array(x, dtype=np.uint32) # convert pixel format from 565(RGB) to 8888(RGBA)114 arr = 0xFF000000 + ((arr & 0xF800) >> 8) + ((arr & 0x07E0) << 5) + ((arr & 0x001F) << 19)115 image = PIL.Image.frombuffer('RGBA', (320, 240), arr, 'raw', 'RGBA', 0, 1)116 self._read_lines() # clear out the remaining buffer117 return image118 # data {0|1|2|3|4|5|6}119 # 0: S11120 # 1: S21121 # 2: /* error term directivity */122 # 3: /* error term source match */123 # 4: /* error term reflection tracking */124 # 5: /* error term transmission tracking */125 # 6: /* error term isolation */126 def get_data(self, array=0) -> np.array:127 if not 0 <= array <= 6:128 raise AttributeError('There are data arrays only from 0 to 6')129 self._send_command('data %d' % array)130 lines = self._read_lines()131 x = []132 for line in lines:133 if line:134 d = line.split(' ')135 x.append(float(d[0]) + float(d[1]) * 1.j)136 return np.array(x)137 def get_info(self) -> [str]:138 self._send_command('info')139 return self._read_lines()140 def get_sweep(self) -> (int, int, int):141 self._send_command('sweep')142 lines = self._read_lines()143 values = lines[0].split(' ')144 values = [int(n) for n in values]145 return values[0], values[1], values[2]146 # you should really recalibrate after changing the sweep147 def set_sweep(self, start, stop, points):148 self._send_command('sweep %d %d %d' % (start, stop, points))149 self._read_lines()150 # sending scan command seems to call pause implicitly151 def set_scan(self, start, stop, points):152 self._send_command('scan %d %d %d' % (start, stop, points))...

Full Screen

Full Screen

test_integration.py

Source:test_integration.py Github

copy

Full Screen

...21import os22from pathlib import Path23import pytest24from github_env import IncorrectInvocation, main25def _read_lines(path: Path) -> list[str]:26 with open(path, 'r') as fd:27 return list(map(str.strip, fd))28@pytest.fixture29def envfile(tmp_path: Path) -> Path:30 return tmp_path / 'env'31def test_no_path():32 if 'GITHUB_ENV' in os.environ:33 del os.environ['GITHUB_ENV']34 with pytest.raises(IncorrectInvocation):35 main(['FOO=bar'])36def test_empty_args():37 if 'GITHUB_ENV' in os.environ:38 del os.environ['GITHUB_ENV']39 with pytest.raises(SystemExit):40 main([])41def test_bad_args(envfile):42 if 'GITHUB_ENV' in os.environ:43 del os.environ['GITHUB_ENV']44 with pytest.raises(IncorrectInvocation):45 main(['-f', str(envfile), 'FOO'])46def test_set(envfile):47 main(['-f', str(envfile), 'FOO=1', 'BAR=2'])48 assert _read_lines(envfile) == ['BAR=2', 'FOO=1']49 main(['-f', str(envfile), 'BAZ=3'])50 assert _read_lines(envfile) == ['BAR=2', 'BAZ=3', 'FOO=1']51def test_rewrite(envfile):52 main(['-f', str(envfile), 'FOO=1', 'FOO=2'])53 assert _read_lines(envfile) == ['FOO=2']54 main(['-f', str(envfile), 'FOO=3'])55 assert _read_lines(envfile) == ['FOO=3']56def test_append(envfile):57 main(['-f', str(envfile), 'FOO=1', 'FOO+=2'])58 assert _read_lines(envfile) == ['FOO=1 2']59 main(['-f', str(envfile), 'FOO+=3'])60 assert _read_lines(envfile) == ['FOO=1 2 3']61def test_append_creating(envfile):62 main(['-f', str(envfile), 'FOO+=1'])63 assert _read_lines(envfile) == ['FOO=1']64def test_prepend(envfile):65 main(['-f', str(envfile), 'FOO=1', 'FOO++=2'])66 assert _read_lines(envfile) == ['FOO=2 1']67 main(['-f', str(envfile), 'FOO++=3'])68 assert _read_lines(envfile) == ['FOO=3 2 1']69def test_prepend_creating(envfile):70 main(['-f', str(envfile), 'FOO++=1'])71 assert _read_lines(envfile) == ['FOO=1']72def test_remove_var(envfile):73 main(['-f', str(envfile), 'FOO=1', 'BAR=2', '!FOO'])74 assert _read_lines(envfile) == ['BAR=2']75 main(['-f', str(envfile), '!BAR'])76 assert _read_lines(envfile) == []77def test_remove_value(envfile):78 main(['-f', str(envfile), 'FOO=1 2 3', 'FOO-=1'])79 assert _read_lines(envfile) == ['FOO=2 3']80 main(['-f', str(envfile), 'FOO-=2'])81 assert _read_lines(envfile) == ['FOO=3']82def test_if(envfile):83 main(['-f', str(envfile), 'FOO=1'])84 main(['-f', str(envfile), '--if', 'true', 'FOO=2'])85 assert _read_lines(envfile) == ['FOO=2']86 main(['-f', str(envfile), '--if', 'false', 'FOO=3'])87 assert _read_lines(envfile) == ['FOO=2']88def test_verbose(envfile, capsys):89 main(['-f', str(envfile), '--verbose', 'FOO=1'])90 captured = capsys.readouterr()91 assert captured.err == '+FOO=1\n'92 main(['-f', str(envfile), '--verbose', 'FOO=2'])93 captured = capsys.readouterr()...

Full Screen

Full Screen

udiffer.py

Source:udiffer.py Github

copy

Full Screen

...29# USE OR OTHER DEALINGS IN THE SOFTWARE.30import argparse31import difflib32import sys33def _read_lines(filename):34 try:35 with open(filename) as f:36 return f.readlines()37 except UnicodeDecodeError:38 with open(filename, encoding='utf_16') as f:39 return f.readlines()40def main():41 parser = argparse.ArgumentParser()42 parser.add_argument('first', metavar='FILE')43 parser.add_argument('second', metavar='FILE')44 config = parser.parse_args()45 first = _read_lines(config.first)46 second = _read_lines(config.second)47 diffs = list(difflib.unified_diff(first, second, fromfile=config.first,48 tofile=config.second))49 if diffs:50 sys.stdout.writelines(diffs)51 sys.exit(1)52if __name__ == '__main__':...

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