How to use test_input method in locust

Best Python code snippet using locust

test_vector.py

Source:test_vector.py Github

copy

Full Screen

1import pytest2import numpy as np3from Vector import *45@pytest.mark.parametrize("test_input,expected", 6[((Vector([1,2]),Vector([-3,2])), 1),7((Vector([5,2]),Vector([0,-1])), -2)])89def test_matmul(test_input, expected):10 assert test_input[0]@test_input[1] == expected1112@pytest.mark.parametrize("test_input,expected", 13[((Vector([1,2]),3), Vector([3,6])),14((Vector([5,2]),0), Vector([0,0]))])1516def test_mul(test_input, expected):17 assert test_input[0]*test_input[1] == expected1819@pytest.mark.parametrize("test_input,expected", 20[(Vector([1,2.0]), Vector([1.0,2])),21(Vector([0,-1]), Vector([0,-1]))])2223def test_eq(test_input,expected):24 assert test_input == expected2526@pytest.mark.parametrize("test_input,expected", 27[(Vector([1,2.0]), Vector([-1.0,-2])),28(Vector([0,-1]), Vector([-0,1]))])2930def test_neg(test_input,expected):31 assert -test_input == expected3233@pytest.mark.parametrize("test_input,expected", 34[((Vector([1,2]),Vector([-3,2])), Vector([-2,4])),35((Vector([5,2]),Vector([0,-1])), Vector([5,1]))])3637def test_add(test_input,expected):38 assert test_input[0] + test_input[1] == expected3940@pytest.mark.parametrize("test_input,expected", 41[((Vector([1,2]),Vector([-3,2])), Vector([4.0,0])),42((Vector([5,2]),Vector([0,-1])), Vector([5,3]))])4344def test_sub(test_input,expected):45 assert test_input[0] - test_input[1] == expected4647@pytest.mark.parametrize("test_input,expected", 48[((Vector([1,2]),0.5), Vector([2,4])),49((Vector([5,2]),3), Vector([5/3,2/3]))])5051def test_truediv(test_input,expected):52 assert test_input[0]/test_input[1] == expected5354@pytest.mark.parametrize("test_input,expected", 55[(Vector([1,2.0]), 2),56(Vector([0,-1,1,2,4]), 5)])5758def test_dimension(test_input,expected):59 assert test_input.dimension() == expected 6061@pytest.mark.parametrize("test_input,expected", 62[(Vector([1,2.0]), np.sqrt(5)),63(Vector([0,-1,1,2,4]), np.sqrt(22))])6465def test_magnitude(test_input,expected):66 assert test_input.magnitude() == expected 6768@pytest.mark.parametrize("test_input,expected", 69[(Vector([1,2.0]), Vector([1,2.0])/np.sqrt(5)),70(Vector([0,-1,1,2,4]), Vector([0,-1,1,2,4])/np.sqrt(22))])7172def test_unit_vector(test_input,expected):73 assert test_input.unit_vector() == expected and round(test_input.unit_vector().magnitude(), 7) == 17475@pytest.mark.parametrize("test_input,expected", 76[(Vector([1,2.0]), 63),77(Vector([0,-1]), 270)])7879def test_polar_angle(test_input,expected):80 assert round(test_input.polar_angle()) == expected 8182@pytest.mark.parametrize("test_input,expected", 83[((Vector([1,2.0]),Vector([2,1,2,4])), DimensionError),84((Vector([1,2.0]), Vector([2,1,3])), DimensionError)])8586def test_DimensionError(test_input,expected):87 with pytest.raises(expected): ...

Full Screen

Full Screen

test_particle.py

Source:test_particle.py Github

copy

Full Screen

1import pytest2import numpy as np3from Particle import Particle, Velocity, Position, Vector, DimensionError45@pytest.mark.parametrize("test_input,expected", 6[(Position([9,8,8]), Position([9,8,8])), 7(Vector([1,3,2,6]), Vector([1,3,2,6])),8(Velocity([0,-4]), Velocity([0,-4]))])910def test_new(test_input, expected):11 assert test_input.new(test_input.components) == expected 1213@pytest.mark.parametrize("test_input,expected", 14[((Position([1,4,2]),Velocity([4,2,3]),2), Position([9,8,8])), 15((Position([-12,0,5]),Velocity([-2,7,1]),6), Position([-24,42,11]))])1617def test_propagate(test_input, expected):18 test_input[0].propagate(test_input[1],test_input[2])19 assert test_input[0] == expected 2021@pytest.mark.parametrize("test_input,expected", 22[((Velocity([1,4,2]),Velocity([4,2,3])), Velocity([5,6,5])), 23((Velocity([-12,0,5]),Velocity([-2,7,1])), Velocity([-14,7,6]))])2425def test_add_velocity(test_input, expected):26 test_input[0].add_velocity(test_input[1])27 assert test_input[0] == expected 2829@pytest.mark.parametrize("test_input,expected", 30[((Velocity([1,4,2]),2), Velocity([1,4,-2])), 31((Velocity([-12,0,5]),1), Velocity([-12,0,5]))])3233def test_invert_component(test_input, expected):34 test_input[0].invert_component(test_input[1])35 assert test_input[0] == expected 3637@pytest.mark.parametrize("test_input,expected", 38[((Particle([2,4,1],[-4,2,0],1,3),4), Position([-14,12,1])), 39((Particle([-3,5,1],[7,-4,2],8,5),6), Position([39,-19,13]))])4041def test_update(test_input, expected):42 test_input[0].update(test_input[1])43 assert test_input[0].position == expected 4445@pytest.mark.parametrize("test_input,expected", 46[((Particle([2,4,1],[-4,2,0],1,3),Particle([2,5,2],[7,25,-4],1,2)), True),47 ((Particle([8,5,2],[-4,2,0],1,3),Particle([-3,0,-2],[-4,2,0],1,3)), False)])4849def test_overlap(test_input, expected):50 assert test_input[0].overlap(test_input[1]) == expected5152@pytest.mark.parametrize("test_input,expected", 53[(Particle([2,4,1],[-4,2,2],1,3), 12), 54(Particle([-3,5],[7,-6],8,5), 340)])5556def test_kinetic_energy(test_input, expected):57 assert round(test_input.kinetic_energy(),5) == expected ...

Full Screen

Full Screen

test_lineparser.py

Source:test_lineparser.py Github

copy

Full Screen

1import pytest2from boostcfg import lineparser3@pytest.mark.parametrize(4 "test_input,expected",5 [6 ("errLogMode = trace", ("errLogMode", "trace")),7 (" \tverbose = true\n ", ("verbose", "true")),8 ("cloneParticle = pion+ pion+", ("cloneParticle", "pion+ pion+")),9 ("decay=Cano D*+ To D0 pion+ \t", ("decay", "Cano D*+ To D0 pion+")),10 ],11)12def test_get_key_value_pair(test_input, expected):13 assert lineparser.get_key_value_pair(test_input) == expected14@pytest.mark.parametrize(15 "test_input", ["something", r" \tsome string # and comment"]16)17def test_get_faulty_key_value_pair(test_input):18 with pytest.raises(SyntaxError):19 lineparser.get_key_value_pair(test_input)20@pytest.mark.parametrize(21 "test_input,expected",22 [23 ("\t don't ignore # and a comment", False),24 (" \t# ignore whitespaces", True),25 ],26)27def test_is_commented(test_input, expected):28 assert lineparser.is_commented(test_input) == expected29@pytest.mark.parametrize(30 "test_input,expected",31 [32 (" some text ", False),33 ("# and a comment", True),34 (" \t# ignore whitespaces", True),35 ],36)37def test_is_empty(test_input, expected):38 assert lineparser.is_empty(test_input) == expected39@pytest.mark.parametrize(40 "test_input,expected",41 [42 ("", ""),43 ("No comments here", "No comments here"),44 ("before # after", "before "),45 ("\t don't ignore # and a comment", "\t don't ignore "),46 (" \t# ignore whitespaces", " \t"),47 ("before# after # and another", "before"),48 ("#Fully commented", ""),49 ],50)51def test_strip_comment(test_input, expected):...

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