diff --git a/Libraries/PyKotor/tests/cli/test_json_commands.py b/Libraries/PyKotor/tests/cli/test_json_commands.py index 67a02752f..2fe1e1ce0 100644 --- a/Libraries/PyKotor/tests/cli/test_json_commands.py +++ b/Libraries/PyKotor/tests/cli/test_json_commands.py @@ -28,6 +28,7 @@ from pykotor.resource.type import ResourceType from pykotor.tools.resource_json import ( _serialize_mdl_face, + _supports_live_progress, export_installation_to_json_tree, iter_installation_resource_documents, serialize_file_resource_document, @@ -285,6 +286,51 @@ def test_to_json_exports_installation_resources_with_readable_wrappers(tmp_path: assert "data" not in wav_payload +def test_supports_live_progress_false_in_ci_even_when_stream_is_tty( + monkeypatch: pytest.MonkeyPatch, +) -> None: + """Live \\r progress bypasses logging; force logger path when CI env is set.""" + + class FakeTTY: + def isatty(self) -> bool: + return True + + monkeypatch.delenv("CI", raising=False) + monkeypatch.delenv("GITHUB_ACTIONS", raising=False) + assert _supports_live_progress(FakeTTY()) is True + + monkeypatch.setenv("CI", "true") + assert _supports_live_progress(FakeTTY()) is False + + monkeypatch.delenv("CI", raising=False) + monkeypatch.setenv("GITHUB_ACTIONS", "1") + assert _supports_live_progress(FakeTTY()) is False + + +def test_supports_live_progress_ci_env_values_are_case_and_whitespace_tolerant( + monkeypatch: pytest.MonkeyPatch, +) -> None: + class FakeTTY: + def isatty(self) -> bool: + return True + + monkeypatch.setenv("CI", " YES ") + assert _supports_live_progress(FakeTTY()) is False + + +def test_supports_live_progress_false_when_stream_not_tty( + monkeypatch: pytest.MonkeyPatch, +) -> None: + monkeypatch.delenv("CI", raising=False) + monkeypatch.delenv("GITHUB_ACTIONS", raising=False) + + class FakePipe: + def isatty(self) -> bool: + return False + + assert _supports_live_progress(FakePipe()) is False + + def test_export_installation_to_json_tree_logs_percentage_progress( tmp_path: Path, caplog: pytest.LogCaptureFixture ) -> None: