MCPcopy Create free account
hub / github.com/DeepL/deepl-python / test_user_agent_exception

Function test_user_agent_exception

tests/test_general.py:222–231  ·  view source on GitHub ↗
(platform_mock, mock_send)

Source from the content-addressed store, hash-verified

220@patch("requests.adapters.HTTPAdapter.send")
221@patch("platform.platform")
222def test_user_agent_exception(platform_mock, mock_send):
223 mock_send.return_value = _build_test_response()
224 platform_mock.side_effect = OSError("mocked test exception")
225 translator = deepl.Translator(os.environ["DEEPL_AUTH_KEY"])
226 translator.translate_text(example_text["EN"], target_lang="DA")
227 ua_header = mock_send.call_args[0][0].headers["User-agent"]
228 assert "deepl-python" in ua_header
229 assert "requests/" not in ua_header
230 assert " python/" not in ua_header
231 assert "(" not in ua_header
232
233
234@needs_mock_proxy_server

Callers

nothing calls this directly

Calls 2

translate_textMethod · 0.95
_build_test_responseFunction · 0.85

Tested by

no test coverage detected