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

Function test_custom_user_agent

tests/test_general.py:166–174  ·  view source on GitHub ↗
(mock_send)

Source from the content-addressed store, hash-verified

164
165@patch("requests.adapters.HTTPAdapter.send")
166def test_custom_user_agent(mock_send):
167 mock_send.return_value = _build_test_response()
168 old_user_agent = deepl.http_client.user_agent
169 deepl.http_client.user_agent = "my custom user agent"
170 translator = deepl.Translator(os.environ["DEEPL_AUTH_KEY"])
171 translator.translate_text(example_text["EN"], target_lang="DA")
172 ua_header = mock_send.call_args[0][0].headers["User-agent"]
173 assert ua_header == "my custom user agent"
174 deepl.http_client.user_agent = old_user_agent
175
176
177@patch("requests.adapters.HTTPAdapter.send")

Callers

nothing calls this directly

Calls 2

translate_textMethod · 0.95
_build_test_responseFunction · 0.85

Tested by

no test coverage detected