Skip to content

test(tools): cover JSON export CI vs TTY progress reporting#262

Draft
cursor[bot] wants to merge 1 commit into
masterfrom
impl/regression-test-coverage-595d
Draft

test(tools): cover JSON export CI vs TTY progress reporting#262
cursor[bot] wants to merge 1 commit into
masterfrom
impl/regression-test-coverage-595d

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented May 20, 2026

Description

Adds focused unit tests for _supports_live_progress and _ExportProgressReporter in resource_json.py, matching the regression fix from fix(json-export): log progress when automated; casefold stream path assert (CI / GITHUB_ACTIONS must force logger-based milestones instead of \r stderr updates even when stderr reports as a TTY).

Type of Change

  • ✅ Test addition or update

Package(s) Affected

  • PyKotor (core library)

Changes Made

  • New file Libraries/PyKotor/tests/tools/test_resource_json_progress.py with seven tests covering:
    • _supports_live_progress returns False when CI or GITHUB_ACTIONS is set to truthy values (including case/whitespace), even if the stream claims to be a TTY.
    • TTY streams outside CI still enable live progress; non-TTY streams do not.
    • When CI disables live updates, progress is emitted via logger.info and the fake TTY stream receives no \r output.
    • When not in CI, a TTY stream receives carriage-return progress output as before.

Risky behavior now covered

  • Automation visibility: In CI, JSON tree export must log percentage milestones through the logger so aggregators and caplog-style tests see progress; stderr \r updates must not be the only signal.
  • False TTY on CI: Some runners attach a pseudo-TTY to stderr; the env-based guard must still disable live stderr progress.

Test files added/updated

  • Added: Libraries/PyKotor/tests/tools/test_resource_json_progress.py

Why these tests materially reduce regression risk

They pin the contract between environment detection (CI / GITHUB_ACTIONS) and progress delivery (logger vs raw stream). A future refactor could easily reintroduce “TTY-only” progress and silently break CI logs and tests that assert on logged percentages, without failing in local development.

Testing

  • 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

Test Results

QT_QPA_PLATFORM=offscreen python3 -m pytest --import-mode=importlib -m "not gui and not slow" --timeout=120 Libraries/PyKotor/tests/tools/test_resource_json_progress.py -v
========================= 7 passed in 0.27s =========================

(Run with PYTHONPATH including Libraries/PyKotor/src and Utility/src, and PyKotor runtime deps installed.)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

Related Issues

Related to automated regression coverage for JSON export / installation-to-json workflows.

Open in Web View Automation 

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 20, 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