How to use get_runner method in locust

Best Python code snippet using locust

test_raisingop2direct_call.py

Source:test_raisingop2direct_call.py Github

copy

Full Screen

2from pypy.rpython.test.test_llinterp import get_interpreter3from pypy.rlib.rarithmetic import ovfcheck4import sys5import py6def get_runner(f, exceptedop, types):7 values = [t() for t in types]8 interp, graph = get_interpreter(f, values)9 for op in support.graph_operations(graph):10 if op.opname == exceptedop:11 break12 else:13 assert False, "op %r not found!"%(exceptedop,)14 t = interp.typer.annotator.translator # FIIISH!15 raisingop2direct_call.raisingop2direct_call(t, [graph])16 def ret(*args):17 assert map(type, args) == types18 return interp.eval_graph(graph, args)19 return ret20def test_test_machinery():21 def f(x, y):22 try:23 return x + y24 except OverflowError:25 return 12326 py.test.raises(AssertionError, "get_runner(f, 'int_add_ovf', [int, int])")27 def f(x, y):28 try:29 return ovfcheck(x + y)30 except OverflowError:31 return 12332 fn = get_runner(f, 'int_add_ovf', [int, int])33 res = fn(0, 0)34 assert res == 035def test_division():36 def f(x, y):37 try:38 return x//y39 except ZeroDivisionError:40 return 12341 fn = get_runner(f, 'int_floordiv_zer', [int, int])42 res = fn(1, 0)43 assert res == 12344 res = fn(-5, 2)45 assert res == -346 # this becomes an int_floordiv_ovf_zer already?47## def g(x, y):48## try:49## return ovfcheck(x//y)50## except OverflowError:51## return 12352## gn = get_runner(g, 'int_floordiv_ovf', [int, int])53## res = gn(-sys.maxint-1, -1)54## assert res == 12355## res = gn(-5, 2)56## assert res == -357 def h(x, y):58 try:59 return ovfcheck(x//y)60 except OverflowError:61 return 12362 except ZeroDivisionError:63 return 24664 hn = get_runner(h, 'int_floordiv_ovf_zer', [int, int])65 res = hn(-sys.maxint-1, -1)66 assert res == 12367 res = hn(1, 0)68 assert res == 24669 res = hn(-5, 2)70 assert res == -371def test_modulo():72 def f(x, y):73 try:74 return x%y75 except ZeroDivisionError:76 return 12377 fn = get_runner(f, 'int_mod_zer', [int, int])78 res = fn(0, 0)79 assert res == 12380 res = fn(-5, 2)81 assert res == 182 # this becomes an int_mod_ovf_zer already?83## def g(x, y):84## try:85## return ovfcheck(x%y)86## except OverflowError:87## return 12388## gn = get_runner(g, 'int_mod_ovf', [int, int])89## res = gn(-sys.maxint-1, -1)90## assert res == 12391## res = gn(-5, 2)92## assert res == -393 def h(x, y):94 try:95 return ovfcheck(x%y)96 except OverflowError:97 return 12398 except ZeroDivisionError:99 return 246100 hn = get_runner(h, 'int_mod_ovf_zer', [int, int])101 res = hn(-sys.maxint-1, -1)102 assert res == 123103 res = hn(1, 0)104 assert res == 246105 res = hn(-5, 2)...

Full Screen

Full Screen

proc.py

Source:proc.py Github

copy

Full Screen

...13 """14 if not proc.is_available():15 test.runner.skip(self, '(proc unavailable)')16 return17 elif not test.runner.get_runner().is_ptraceable():18 test.runner.skip(self, '(DisableDebuggerAttachment is set)')19 return20 runner = test.runner.get_runner()21 runner_pid, tor_cwd = runner.get_pid(), runner.get_tor_cwd()22 self.assertEqual(tor_cwd, proc.cwd(runner_pid))23 def test_uid(self):24 """25 Checks that stem.util.proc.uid matches our tor instance's uid.26 """27 if not proc.is_available():28 test.runner.skip(self, '(proc unavailable)')29 return30 tor_pid = test.runner.get_runner().get_pid()31 self.assertEqual(os.geteuid(), proc.uid(tor_pid))32 def test_memory_usage(self):33 """34 Checks that stem.util.proc.memory_usage looks somewhat reasonable.35 """36 if not proc.is_available():37 test.runner.skip(self, '(proc unavailable)')38 return39 tor_pid = test.runner.get_runner().get_pid()40 res_size, vir_size = proc.memory_usage(tor_pid)41 # checks that they're larger than a kilobyte42 self.assertTrue(res_size > 1024)43 self.assertTrue(vir_size > 1024)44 def test_stats(self):45 """46 Checks that stem.util.proc.stats looks somewhat reasonable.47 """48 if not proc.is_available():49 test.runner.skip(self, '(proc unavailable)')50 return51 tor_cmd = test.runner.get_runner().get_tor_command(True)52 tor_pid = test.runner.get_runner().get_pid()53 command, utime, stime, start_time = proc.stats(tor_pid, 'command', 'utime', 'stime', 'start time')54 self.assertEqual(tor_cmd, command)55 self.assertTrue(float(utime) > 0)56 self.assertTrue(float(stime) >= 0)57 self.assertTrue(float(start_time) > proc.system_start_time())58 def test_connections(self):59 """60 Checks for our control port in the stem.util.proc.connections output if61 we have one.62 """63 runner = test.runner.get_runner()64 if not proc.is_available():65 test.runner.skip(self, '(proc unavailable)')66 return67 elif test.runner.Torrc.PORT not in runner.get_options():68 test.runner.skip(self, '(no control port)')69 return70 elif not test.runner.get_runner().is_ptraceable():71 test.runner.skip(self, '(DisableDebuggerAttachment is set)')72 return73 elif not os.access('/proc/net/tcp', os.R_OK) or not os.access('/proc/net/udp', os.R_OK):74 test.runner.skip(self, '(proc lacks read permissions)')75 return76 # making a controller connection so that we have something to query for77 with runner.get_tor_socket():78 tor_pid = test.runner.get_runner().get_pid()79 for conn in proc.connections(tor_pid):80 if ('127.0.0.1', test.runner.CONTROL_PORT) == conn[:2]:81 return...

Full Screen

Full Screen

test.py

Source:test.py Github

copy

Full Screen

...36 '--testrunner', action='store', dest='testrunner',37 help='Tells Django to use specified test runner class instead of '38 'the one specified by the TEST_RUNNER setting.',39 )40 test_runner_class = get_runner(settings, self.test_runner)41 if hasattr(test_runner_class, 'add_arguments'):42 test_runner_class.add_arguments(parser)43 def handle(self, *test_labels, **options):44 from django.conf import settings45 from django.test.utils import get_runner46 TestRunner = get_runner(settings, options['testrunner'])47 test_runner = TestRunner(**options)48 failures = test_runner.run_tests(test_labels)49 if failures:...

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 locust 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