1717import pytest
1818
1919import language_tool_python
20- from language_tool_python import download_lt
2120from language_tool_python .download_lt import (
2221 _LTP_BYPASS_VERIFIED_DOWNLOADS_ENV_VAR ,
2322 _LTP_DOWNLOAD_SHA256_ENV_VAR ,
@@ -186,7 +185,7 @@ def test_http_get_rejects_oversized_content_length(
186185 )
187186 response = MockDownloadResponse (payload )
188187 response .headers ["Content-Length" ] = "2"
189- monkeypatch .setattr (download_lt , "_MAX_DOWNLOAD_BYTES" , 1 )
188+ monkeypatch .setattr (language_tool_python . download_lt , "_MAX_DOWNLOAD_BYTES" , 1 )
190189
191190 with (
192191 patch (
@@ -207,11 +206,14 @@ def test_max_download_bytes_uses_env_override(
207206 env .setenv (
208207 _LTP_MAX_DOWNLOAD_BYTES_ENV_VAR , str (EXPECTED_DOWNLOAD_BYTES_OVERRIDE )
209208 )
210- importlib .reload (download_lt )
209+ importlib .reload (language_tool_python . download_lt )
211210
212- assert download_lt ._MAX_DOWNLOAD_BYTES == EXPECTED_DOWNLOAD_BYTES_OVERRIDE
211+ assert (
212+ language_tool_python .download_lt ._MAX_DOWNLOAD_BYTES
213+ == EXPECTED_DOWNLOAD_BYTES_OVERRIDE
214+ )
213215 finally :
214- importlib .reload (download_lt )
216+ importlib .reload (language_tool_python . download_lt )
215217
216218
217219def test_http_get_rejects_oversized_stream (
@@ -223,7 +225,9 @@ def test_http_get_rejects_oversized_stream(
223225 )
224226 response = MockDownloadResponse (payload )
225227 response .headers = {}
226- monkeypatch .setattr (download_lt , "_MAX_DOWNLOAD_BYTES" , len (payload ) - 1 )
228+ monkeypatch .setattr (
229+ language_tool_python .download_lt , "_MAX_DOWNLOAD_BYTES" , len (payload ) - 1
230+ )
227231
228232 with (
229233 patch (
@@ -244,7 +248,9 @@ def test_http_get_rejects_oversized_stream_with_small_content_length(
244248 )
245249 response = MockDownloadResponse (payload )
246250 response .headers ["Content-Length" ] = "1"
247- monkeypatch .setattr (download_lt , "_MAX_DOWNLOAD_BYTES" , len (payload ) - 1 )
251+ monkeypatch .setattr (
252+ language_tool_python .download_lt , "_MAX_DOWNLOAD_BYTES" , len (payload ) - 1
253+ )
248254
249255 with (
250256 patch (
@@ -279,13 +285,13 @@ def test_latest_snapshot_uses_latest_download_url_and_current_date(
279285) -> None :
280286 """Test that latest remains a snapshot alias installed under the current date."""
281287 monkeypatch .setattr (
282- download_lt ,
288+ language_tool_python . download_lt ,
283289 "_BASE_URL_SNAPSHOT" ,
284290 "https://example.test/snapshots/" ,
285291 )
286292
287293 FixedDatetime .current_datetime = datetime (2024 , 5 , 14 , tzinfo = timezone .utc )
288- monkeypatch .setattr (download_lt , "datetime" , FixedDatetime )
294+ monkeypatch .setattr (language_tool_python . download_lt , "datetime" , FixedDatetime )
289295 local_language_tool = LocalLanguageTool .from_version_name ("latest" )
290296
291297 assert local_language_tool .version_name == "20240514"
@@ -302,7 +308,7 @@ def test_release_download_url_uses_new_release_base_from_6_7(
302308) -> None :
303309 """Test that releases 6.7 and newer include the version in the base URL."""
304310 monkeypatch .setattr (
305- download_lt ,
311+ language_tool_python . download_lt ,
306312 "_BASE_URL_NEW_RELEASES" ,
307313 "https://example.test/releases/LanguageTool-{version}/" ,
308314 )
@@ -322,7 +328,7 @@ def test_release_download_url_keeps_main_release_base_for_6_6(
322328) -> None :
323329 """Test that release 6.6 keeps using the versioned filename."""
324330 monkeypatch .setattr (
325- download_lt ,
331+ language_tool_python . download_lt ,
326332 "_BASE_URL_RELEASE" ,
327333 "https://example.test/download/" ,
328334 )
@@ -340,7 +346,7 @@ def test_release_download_url_keeps_main_release_base_before_6_7(
340346) -> None :
341347 """Test that earlier 6.x releases keep using the versioned filename."""
342348 monkeypatch .setattr (
343- download_lt ,
349+ language_tool_python . download_lt ,
344350 "_BASE_URL_RELEASE" ,
345351 "https://example.test/download/" ,
346352 )
@@ -358,7 +364,7 @@ def test_release_download_url_keeps_archive_base_before_6_0(
358364) -> None :
359365 """Test that older supported releases keep using the archive base URL."""
360366 monkeypatch .setattr (
361- download_lt ,
367+ language_tool_python . download_lt ,
362368 "_BASE_URL_ARCHIVE" ,
363369 "https://example.test/archive/" ,
364370 )
@@ -486,7 +492,7 @@ def test_snapshot_download_renames_archive_root_to_requested_date(
486492 )
487493 local_language_tool = LocalLanguageTool .from_version_name (requested_snapshot )
488494 monkeypatch .setattr (
489- download_lt ,
495+ language_tool_python . download_lt ,
490496 "_confirm_java_compatibility" ,
491497 skip_java_compatibility_check ,
492498 )
@@ -499,7 +505,7 @@ def test_snapshot_download_renames_archive_root_to_requested_date(
499505 ),
500506 ):
501507 monkeypatch .setattr (
502- download_lt ,
508+ language_tool_python . download_lt ,
503509 "get_language_tool_download_path" ,
504510 lambda : temp_dir ,
505511 )
@@ -525,10 +531,10 @@ def test_latest_snapshot_download_renames_archive_root_to_current_date(
525531 {"LanguageTool-6.9-SNAPSHOT/languagetool-server.jar" : b"jar" },
526532 )
527533 FixedDatetime .current_datetime = datetime (2024 , 5 , 14 , tzinfo = timezone .utc )
528- monkeypatch .setattr (download_lt , "datetime" , FixedDatetime )
534+ monkeypatch .setattr (language_tool_python . download_lt , "datetime" , FixedDatetime )
529535 local_language_tool = LocalLanguageTool .from_version_name ("latest" )
530536 monkeypatch .setattr (
531- download_lt ,
537+ language_tool_python . download_lt ,
532538 "_confirm_java_compatibility" ,
533539 skip_java_compatibility_check ,
534540 )
@@ -541,7 +547,7 @@ def test_latest_snapshot_download_renames_archive_root_to_current_date(
541547 ),
542548 ):
543549 monkeypatch .setattr (
544- download_lt ,
550+ language_tool_python . download_lt ,
545551 "get_language_tool_download_path" ,
546552 lambda : temp_dir ,
547553 )
0 commit comments