From 0ece54c22e5c9cd4bf35f7bfa1e4b122dada05bc Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 22 May 2026 10:04:21 +0000 Subject: [PATCH 1/2] test(tlk): regression for empty xml string element Co-authored-by: Boden --- Libraries/PyKotor/tests/resource/formats/test_tlk.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Libraries/PyKotor/tests/resource/formats/test_tlk.py b/Libraries/PyKotor/tests/resource/formats/test_tlk.py index a097ac1ce..abfae83e2 100644 --- a/Libraries/PyKotor/tests/resource/formats/test_tlk.py +++ b/Libraries/PyKotor/tests/resource/formats/test_tlk.py @@ -78,6 +78,18 @@ def test_xml_io(self): tlk = read_tlk(data) self.validate_io(tlk) + def test_xml_reader_self_closing_string_has_empty_text(self): + """Empty ```` must load as empty dialogue text (not raise).""" + xml_doc = ( + '' + '' + '' + "" + ) + tlk = TLKXMLReader(xml_doc.encode("utf-8")).load() + self.assertEqual(tlk[0].text, "") + self.assertEqual(str(tlk[0].voiceover), "") + def test_json_io(self): self.assertEqual(detect_tlk(JSON_TEST_DATA.encode("utf-8")), ResourceType.TLK_JSON) From 1eb866787b945269dd3fccd162b7bb23dc7dd807 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 22 May 2026 10:04:25 +0000 Subject: [PATCH 2/2] test(resource_json): cover ci gating for live stderr progress Co-authored-by: Boden --- .../tests/test_resource_json_progress.py | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Libraries/PyKotor/tests/test_resource_json_progress.py diff --git a/Libraries/PyKotor/tests/test_resource_json_progress.py b/Libraries/PyKotor/tests/test_resource_json_progress.py new file mode 100644 index 000000000..f1ed4b6b3 --- /dev/null +++ b/Libraries/PyKotor/tests/test_resource_json_progress.py @@ -0,0 +1,49 @@ +"""Regression tests for JSON export progress reporting (CI vs TTY).""" + +from __future__ import annotations + +from io import StringIO + +import pytest + +from pykotor.tools.resource_json import _supports_live_progress + + +class _FakeTTYStream: + """Minimal stream that reports as a TTY (like stderr under ``script``).""" + + def isatty(self) -> bool: + return True + + +def test_supports_live_progress_true_when_tty_and_not_ci(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.delenv("CI", raising=False) + monkeypatch.delenv("GITHUB_ACTIONS", raising=False) + assert _supports_live_progress(_FakeTTYStream()) is True + + +@pytest.mark.parametrize( + ("env_name", "env_value"), + [ + ("CI", "true"), + ("CI", "1"), + ("CI", "yes"), + ("GITHUB_ACTIONS", "true"), + ("GITHUB_ACTIONS", "1"), + ], +) +def test_supports_live_progress_false_in_ci_even_if_stream_is_tty( + monkeypatch: pytest.MonkeyPatch, + env_name: str, + env_value: str, +) -> None: + monkeypatch.delenv("CI", raising=False) + monkeypatch.delenv("GITHUB_ACTIONS", raising=False) + monkeypatch.setenv(env_name, env_value) + assert _supports_live_progress(_FakeTTYStream()) is False + + +def test_supports_live_progress_false_when_not_tty(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.delenv("CI", raising=False) + monkeypatch.delenv("GITHUB_ACTIONS", raising=False) + assert _supports_live_progress(StringIO()) is False