Skip to content

test(resource-json): regression coverage for CI JSON export progress#265

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

test(resource-json): regression coverage for CI JSON export progress#265
cursor[bot] wants to merge 1 commit into
masterfrom
impl/regression-test-coverage-9d58

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented May 23, 2026

Description

Adds focused unit tests for _supports_live_progress and _ExportProgressReporter in resource_json.py, matching the recent fix(json-export) behavior where CI and GitHub Actions force structured logger.info milestones instead of carriage-return live stderr updates.

Type of Change

  • ✅ Test addition or update

Package(s) Affected

  • PyKotor (core library)

Changes Made

  • New file Libraries/PyKotor/tests/test_tools/test_resource_json_progress.py (under test_tools/ so collection does not depend on tests/cli/conftest.py).
  • Covers: progress bar clamping, CI / GITHUB_ACTIONS env disabling live TTY progress, non-TTY streams, TTY outside automation, and integration that _ExportProgressReporter logs percentage lines to the logger when CI=true without writing \r spam to the stream.

Risky behavior now covered

  • Automation visibility: Ensures CI / GITHUB_ACTIONS truthy values disable _supports_live_progress even when stderr reports as a TTY, so log aggregators and caplog receive logger.info progress lines instead of missing live-only updates.
  • Progress bar bounds: _format_progress_bar clamps negative and over-100 percentages so export UI cannot produce malformed bars.

Test files added/updated

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

Why these tests materially reduce regression risk

The JSON installation/directory export path processes large trees; regressions that switch CI back to live \r updates silently drop progress from structured logs and break assertions that depend on milestone messages. These tests pin the environment gating and the logger-vs-stream contract with minimal, deterministic fixtures (no RobustLogger subclassing, which hits singleton/metaclass behavior).

Testing

  • cd Libraries/PyKotor && uv sync --extra dev && uv pip install pytest-timeout
  • QT_QPA_PLATFORM=offscreen uv run pytest --import-mode=importlib -m "not gui and not slow" --timeout=120 tests/test_tools/test_resource_json_progress.py tests/cli/test_json_commands.py -v (37 passed)

Note: Running pytest tests from Libraries/PyKotor without the full workspace optional extras (e.g. glm, qtpy) produced collection errors for GL and Qt utility modules; CI uses a fuller install. The new tests only require the default PyKotor dev sync.

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 (scoped run above)

Fixes #
Closes #
Related to #

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