Best Python code snippet using avocado_python
test_transport.py
Source:test_transport.py
...19 self.headers = {}20 self.url = 'http://example.org'21 self.status_code = 20022# Test transport errors.23def test_unknown_scheme():24 with pytest.raises(NetworkError):25 determine_transport(transports, 'ftp://example.org')26def test_missing_scheme():27 with pytest.raises(NetworkError):28 determine_transport(transports, 'example.org')29def test_missing_hostname():30 with pytest.raises(NetworkError):31 determine_transport(transports, 'http://')32# Test basic transition types.33def test_get(monkeypatch, http):34 def mockreturn(self, request, *args, **kwargs):35 return MockResponse(b'{"_type": "document", "example": 123}')36 monkeypatch.setattr(requests.Session, 'send', mockreturn)37 link = Link(url='http://example.org', action='get')...
test_basics.py
Source:test_basics.py
2from outgoing import resolve_password3from outgoing.errors import InvalidPasswordError4def test_string_password() -> None:5 assert resolve_password("foo") == "foo"6def test_unknown_scheme() -> None:7 with pytest.raises(InvalidPasswordError) as excinfo:8 resolve_password({"foo": {}})9 assert str(excinfo.value) == (10 "Invalid password configuration: Unsupported password scheme 'foo'"11 )12def test_multiple_keys() -> None:13 with pytest.raises(InvalidPasswordError) as excinfo:14 resolve_password({"foo": {}, "env": "SECRET"})15 assert str(excinfo.value) == (16 "Invalid password configuration: Password must be either a string or an"17 " object with exactly one field"18 )19def test_invalid_env_configpath() -> None:20 with pytest.raises(InvalidPasswordError) as excinfo:...
test_connection.py
Source:test_connection.py
...13 conn = simplefetch.Connection(scheme='http')14 conn.request('GET', 'http://www.example.com', None, {})15 resp = conn.response()16 self.assertEqual(resp.status, 200)17 def test_unknown_scheme(self):18 with self.assertRaises(simplefetch.UnknownConnectionSchemeException):19 conn = simplefetch.Connection(scheme='ftp')20 21if __name__ == '__main__':...
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!!