Skip to content

test(regression): CI JSON progress and BIF-sliced MDL reads#254

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

test(regression): CI JSON progress and BIF-sliced MDL reads#254
cursor[bot] wants to merge 1 commit into
masterfrom
cursor/regression-test-coverage-36a8

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented May 13, 2026

Description

Adds focused regression tests for two recently merged high-risk areas: JSON export progress reporting under CI-like environment variables, and binary MDL loading when the resource lives at a non-zero offset inside a larger buffer (BIF / chitin slice semantics).

Type of Change

  • ✅ Test addition or update

Package(s) Affected

  • PyKotor (core library)

Risky behavior now covered

  • _supports_live_progress in resource_json: When CI or GITHUB_ACTIONS is set to a truthy string, live \r progress is disabled even if stderr claims to be a TTY, so log-based assertions and aggregators still see percentage milestones via logger.info.
  • MDLBinaryReader offset handling: Reading the same binary MDL from a padded buffer with offset/size (simulating a BIF entry) must match reading the standalone file—guards against double-counting offset+12 and bogus seeks.

Test files added/updated

  • Libraries/PyKotor/tests/test_resource_json_progress_regressions.py (new)
  • Libraries/PyKotor/tests/resource/formats/test_mdl_bif_slice_offset.py (new)

Why these tests materially reduce regression risk

  • JSON export: A subtle CI-only behavior change can silently drop progress from structured logs while still “working” in the terminal; explicit env-matrix tests fail fast if someone removes or weakens the CI guard.
  • MDL from archives: Wrong slice math corrupts geometry or fails parsing for every MDL pulled from chitin.key / BIFs; comparing slice vs file is a minimal end-to-end proof without depending on full models.bif roundtrips.

Testing

Command (from Libraries/PyKotor, uv with dev extra):

QT_QPA_PLATFORM=offscreen uv run python -m pytest --rootdir=/workspace/Libraries/PyKotor --import-mode=importlib -m "not gui and not slow" tests/test_resource_json_progress_regressions.py tests/resource/formats/test_mdl_bif_slice_offset.py -v

Result: 5 passed (0.13s). Tests are deterministic (temp env via monkeypatch, in-repo binary fixture).

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • 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

Related Issues

Related to recent fixes on resource_json CI progress and MDLBinaryReader BIF offset handling.

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 13, 2026
from pykotor.resource.formats.mdl import read_mdl


def _smallest_mdl_fixture() -> Path:
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