Best Python code snippet using locust
test_drawing.py
Source:test_drawing.py  
...307        assert state['stroke_weight'] == 2.0308        assert state['stroke_opacity'] == 0.6309        assert state['fill_color'] == drawing.DEFAULT_FILL_COLOR310        assert state['fill_opacity'] == 0.2311    def test_custom_arguments(self):312        polygon = drawing.Polygon(313            self.path,314            stroke_color=(1, 3, 5),315            stroke_weight=10.0,316            stroke_opacity=0.87,317            fill_color=(7, 9, 11),318            fill_opacity=0.76319        )320        state = polygon.get_state()321        assert state['stroke_color'] == 'rgb(1,3,5)'322        assert state['stroke_weight'] == 10.0323        assert state['stroke_opacity'] == 0.87324        assert state['fill_color'] == 'rgb(7,9,11)'325        assert state['fill_opacity'] == 0.76326    def test_invalid_stroke_opacity(self):327        with self.assertRaises(traitlets.TraitError):328            drawing.Polygon(self.path, stroke_opacity=-0.2)329        with self.assertRaises(traitlets.TraitError):330            drawing.Polygon(self.path, stroke_opacity=1.2)331        with self.assertRaises(traitlets.TraitError):332            drawing.Polygon(self.path, stroke_opacity='not-a-float')333    def test_invalid_fill_opacity(self):334        with self.assertRaises(traitlets.TraitError):335            drawing.Polygon(self.path, fill_opacity=-0.2)336        with self.assertRaises(traitlets.TraitError):337            drawing.Polygon(self.path, fill_opacity=1.2)338        with self.assertRaises(traitlets.TraitError):339            drawing.Polygon(self.path, fill_opacity='not-a-float')340class PolygonOptions(unittest.TestCase):341    def test_to_polygon_defaults(self):342        path = [(10.0, 20.0), (5.0, 30.0), (-5.0, 10.0)]343        expected_polygon = drawing.Polygon(path)344        actual_polygon = drawing.PolygonOptions().to_polygon(path)345        assert actual_polygon.path == expected_polygon.path346        assert actual_polygon.stroke_color == expected_polygon.stroke_color347        assert actual_polygon.stroke_weight == expected_polygon.stroke_weight348        assert actual_polygon.stroke_opacity == expected_polygon.stroke_opacity349        assert actual_polygon.fill_color == expected_polygon.fill_color350        assert actual_polygon.fill_opacity == expected_polygon.fill_opacity351class Circle(unittest.TestCase):352    def setUp(self):353        self.center = (20.0, 24.0)354        self.radius = 4.0e5355    def test_kwargs(self):356        circle = drawing.Circle(center=self.center, radius=self.radius)357        assert circle.get_state()['center'] == self.center358        assert circle.get_state()['radius'] == self.radius359    def test_missing_center(self):360        with self.assertRaises(TypeError):361            drawing.Circle(radius=self.radius)362    def test_missing_radius(self):363        with self.assertRaises(TypeError):364            drawing.Circle(center=self.center)365    def test_defaults(self):366        circle = drawing.Circle(self.center, self.radius)367        state = circle.get_state()368        assert state['stroke_color'] == drawing.DEFAULT_STROKE_COLOR369        assert state['stroke_weight'] == 2.0370        assert state['stroke_opacity'] == 0.6371        assert state['fill_color'] == drawing.DEFAULT_FILL_COLOR372        assert state['fill_opacity'] == 0.2373    def test_custom_arguments(self):374        circle = drawing.Circle(375            self.center,376            self.radius,377            stroke_color=(1, 3, 5),378            stroke_weight=10.0,379            stroke_opacity=0.87,380            fill_color=(7, 9, 11),381            fill_opacity=0.76382        )383        state = circle.get_state()384        assert state['stroke_color'] == 'rgb(1,3,5)'385        assert state['stroke_weight'] == 10.0386        assert state['stroke_opacity'] == 0.87387        assert state['fill_color'] == 'rgb(7,9,11)'...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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
