Skip to content

test(cli): cover JSON export live-progress CI env gates#257

Draft
cursor[bot] wants to merge 1 commit into
masterfrom
cursor/regression-test-coverage-4fa4
Draft

test(cli): cover JSON export live-progress CI env gates#257
cursor[bot] wants to merge 1 commit into
masterfrom
cursor/regression-test-coverage-4fa4

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented May 16, 2026

Description

Adds unit tests for _supports_live_progress in resource_json.py, which gates whether installation JSON export uses live \r stderr updates versus logger.info milestones. Recent production changes treat CI / GITHUB_ACTIONS as forcing the logger path so CI and log aggregators reliably capture percentage progress.

Type of Change

  • Test addition or update

Package(s) Affected

  • PyKotor (core library)

Risky behavior now covered

  • CI / GitHub Actions env: When stderr is still a TTY (common in some runners), live progress would skip structured logs; the code now disables live updates when CI or GITHUB_ACTIONS is truthy (true / 1 / yes, case-insensitive). Tests assert False is returned for a fake TTY stream under those env vars, and True when they are unset and the stream reports a TTY.
  • Non-TTY streams: Asserts False when isatty() is false and CI env is clear (unchanged path, guards regressions).

Test files added/updated

  • Libraries/PyKotor/tests/cli/test_json_commands.py — three tests: CI vs TTY interaction, whitespace/case on CI, non-TTY stream.

Why this reduces regression risk

This logic is easy to break with a small refactor (e.g. reordering isatty vs env checks) and has direct impact on observability and the existing caplog-based CLI test for percentage milestones. Deterministic tests use monkeypatch only; no network or filesystem dependencies.

Testing

Ran (from Libraries/PyKotor with dev venv):

QT_QPA_PLATFORM=offscreen .venv/bin/python -m pytest --import-mode=importlib -m "not gui and not slow" tests/cli/test_json_commands.py -k "supports_live_progress" -v

Result: 3 passed.

Test Results

3 passed, 28 deselected
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 16, 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