(mock_send)
| 164 | |
| 165 | @patch("requests.adapters.HTTPAdapter.send") |
| 166 | def 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") |
nothing calls this directly
no test coverage detected