How to use test_request_connection_error method in locust

Best Python code snippet using locust

test_request.py

Source:test_request.py Github

copy

Full Screen

...26 data=json.dumps(payload), timeout=timeout, allow_redirects=True)27 except Exception as e:28 pytest.skip("can not connect to local blockchain", allow_module_level=True)29@pytest.mark.run(order=1)30def test_request_connection_error():31 # Find available port32 s = socket.socket()33 s.bind(('localhost', 0))34 port = s.getsockname()[1]35 s.close()36 if port == 0:37 pytest.skip("could not find available port")38 bad_endpoint = f'http://localhost:{port}'39 bad_request = None40 try:41 bad_request = request.rpc_request('hmyv2_getNodeMetadata', endpoint=bad_endpoint)42 except Exception as e:43 assert isinstance(e, exceptions.RequestsError)44 assert bad_request is None...

Full Screen

Full Screen

test_client.py

Source:test_client.py Github

copy

Full Screen

...27 mock_request.return_value = mock_response28 with pytest.raises(IntercomHTTPError):29 IntercomAPI.request("GET", "users", {"user_id": "TheRealJYD"})30 @mock.patch("intercom.client.requests.request")31 def test_request_connection_error(self, mock_request):32 mock_request.side_effect = requests.exceptions.ConnectionError()33 with pytest.raises(IntercomConnectionError):...

Full Screen

Full Screen

test_base.py

Source:test_base.py Github

copy

Full Screen

...5def test_request_retry():6 pass7def test_request_timeout():8 pass9def test_request_connection_error(requests_mock):10 requests_mock.get('https://test.io', exc=ConnectionError)11 requests_mock.post('https://test.io', exc=ConnectionError)12 base = BaseClient()13 assert base._request_get('https://test.io','token') is False14 assert base._request_post('https://test.io','token') is False15def test_cache(requests_mock):16 requests_mock.get('https://test-cache.io', text='cached response')17 base = BaseClient()18 response = base._request_get('https://test-cache.io','token', ttl = 2)19 assert response.from_cache == False20 21 response_cached = base._request_get('https://test-cache.io','token')...

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