Skip to content

test(resource-json): regression coverage for CI vs TTY export progress#260

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

test(resource-json): regression coverage for CI vs TTY export progress#260
cursor[bot] wants to merge 1 commit into
masterfrom
impl/regression-test-coverage-08ce

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented May 19, 2026

Description

Adds focused unit tests for _supports_live_progress in resource_json, matching the behavior introduced in fix(json-export): log progress when automated; casefold stream path assert (commit c7e573d). When CI or GITHUB_ACTIONS is set, live \r progress on stderr is disabled so percentage milestones go through the logger (visible to caplog and log aggregators). When those env vars are unset, behavior falls back to stream.isatty().

Type of Change

  • ✅ Test addition or update

Package(s) Affected

  • PyKotor (core library)

Changes Made

  • New file Libraries/PyKotor/tests/test_resource_json_progress.py with parametrized checks for CI / GITHUB_ACTIONS truthy values, TTY vs non-TTY streams, and streams without isatty.

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

cd Libraries/PyKotor && uv sync && uv pip install pytest pytest-timeout ruff
.venv/bin/python -m pytest --import-mode=importlib --timeout=120 tests/test_resource_json_progress.py -v  # 10 passed
.venv/bin/python -m pytest --import-mode=importlib --timeout=120 tests/cli/test_json_commands.py::test_export_installation_to_json_tree_logs_percentage_progress -v  # 1 passed
.venv/bin/ruff check tests/test_resource_json_progress.py

Risky behavior now covered

  • JSON installation export progress in CI: Removing or breaking the CI / GITHUB_ACTIONS guard would again use live carriage-return updates on a pseudo-TTY, hiding progress from structured logs and breaking tests that assert on logger.info percentage lines.

Test files added/updated

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

Why these tests materially reduce regression risk

They pin the contract between automation environment detection and progress reporting. That path is easy to break when refactoring _ExportProgressReporter or stderr handling, and the failure mode (silent or invisible progress in CI) is subtle and expensive to catch manually.

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 regression-test coverage automation (cron).

Additional Notes

Tests use monkeypatch for env vars and small StringIO subclasses so they stay deterministic and independent of the host CI environment.

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