Skip to content

test: TLK XML empty string and resource_json CI progress coverage#264

Draft
cursor[bot] wants to merge 2 commits into
masterfrom
impl/regression-test-coverage-bd7b
Draft

test: TLK XML empty string and resource_json CI progress coverage#264
cursor[bot] wants to merge 2 commits into
masterfrom
impl/regression-test-coverage-bd7b

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented May 22, 2026

Description

Adds focused regression tests for two recently changed production paths on master: TLK XML parsing when <string> has no text node, and _supports_live_progress so JSON/archive export uses log-friendly progress in CI instead of carriage-return live updates.

Type of Change

  • ✅ Test addition or update

Package(s) Affected

  • PyKotor (core library)

Risky behavior now covered

  1. TLKXMLReader / io_tlk_xml: A <string id="N"/> or otherwise missing text node must deserialize to an empty string. This replaced a ValueError path; the test locks in the intended tolerant behavior so future edits do not accidentally reintroduce hard failures for valid-looking XML from editors or minimizers.

  2. _supports_live_progress in resource_json: When CI or GITHUB_ACTIONS is set to a truthy value, live TTY-style progress must be disabled even if the stream reports isatty() == True, so percentage milestones go through the logger and show up in caplog and CI logs. Clears env in the positive case so the test stays deterministic under GitHub Actions.

Test files added/updated

  • Libraries/PyKotor/tests/resource/formats/test_tlk.pytest_xml_reader_self_closing_string_has_empty_text
  • Libraries/PyKotor/tests/test_resource_json_progress.py — new module for _supports_live_progress (TTY vs non-TTY, CI / GITHUB_ACTIONS variants)

Why these tests materially reduce regression risk

  • TLK: Talk tables are user-edited as XML; empty entries are plausible. A regression back to raising would break pipelines on benign files.
  • Progress: Silent or missing progress in automation was the motivation for the production change; without tests, a refactor could drop the env checks and restore flaky or invisible CI behavior.

Testing

Libraries/PyKotor/.venv/bin/python -m pytest --import-mode=importlib -m "not gui and not slow" --timeout=120 \
  Libraries/PyKotor/tests/test_resource_json_progress.py \
  Libraries/PyKotor/tests/resource/formats/test_tlk.py -v
# 14 passed
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • New and existing unit tests pass locally with my changes

Related Issues

Related to recent master changes in io_tlk_xml.py and resource_json.py (TLK empty text handling; CI-aware live progress).

Additional Notes

Tests clear CI / GITHUB_ACTIONS where needed so they are not environment-flaky under Actions.

Open in Web View Automation 

cursoragent and others added 2 commits May 22, 2026 10:04
Co-authored-by: Boden <th3w1zard1@users.noreply.github.com>
Co-authored-by: Boden <th3w1zard1@users.noreply.github.com>
@github-actions github-actions Bot added python Pull requests that update python code libraries size/S Small PR (30-100 lines) labels May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libraries python Pull requests that update python code size/S Small PR (30-100 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant