Skip to content

test(diff): extend merge-to-TSLPatcher regression coverage - #179

Merged
oldrepublicwizard merged 2 commits into
masterfrom
cursor/regression-test-coverage-66a5
Apr 28, 2026
Merged

test(diff): extend merge-to-TSLPatcher regression coverage#179
oldrepublicwizard merged 2 commits into
masterfrom
cursor/regression-test-coverage-66a5

Conversation

@cursor

@cursor cursor Bot commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

Description

Adds regression tests for recent diff/merge-to-TSLPatcher behavior: default conflict artifact location, ambiguous base resource resolution, and merge conflict policy normalization.

Type of Change

  • ✅ Test addition or update

Package(s) Affected

  • PyKotor (core library)

Risky behavior now covered

  • Ambiguous base DLG resolution: When --merge-source is a folder tree containing two copies of the same resname.dlg, the merge workflow must fail with MergeConflictError (message mentions ambiguity) instead of silently picking one file. This guards against wrong patches when modders mirror resources under multiple subfolders.
  • Default conflict artifact directory: With merge_conflict_policy="artifact" and no merge_conflict_output_path, artifacts must land under {tslpatchdata}/merge_conflicts/ (README.txt, conflicts.json), matching _write_merge_conflict_artifacts in merge.py.
  • Policy string normalization: _normalize_merge_conflict_policy maps known policies and defaults unknown/empty values to "mod-a", so CLI typos do not produce undefined behavior.

Test files added/updated

  • Libraries/PyKotor/tests/tslpatcher/diff/test_diff_tslpatcher.py

Why these tests materially reduce regression risk

  • Silent wrong-base bugs in merge workflows are high blast radius (bad changes.ini for end users). The ambiguity test pins the explicit failure mode.
  • Artifact output path is user-facing; a regression could drop files in an unexpected place or skip writing them; the default-path test locks the contract.
  • Policy normalization is a small pure function; unit tests are cheap and prevent accidental policy string drift.

Testing

  • uv run pytest --import-mode=importlib -m "not gui and not slow" --timeout=120 Libraries/PyKotor/tests/tslpatcher/diff/test_diff_tslpatcher.py -k "test_merge_tslpatcher_artifact_writes or test_merge_tslpatcher_raises_when_base or test_normalize_merge"

Note: On a fresh Linux agent, libegl1 was required for PyQt6 import during pytest; CI images that already ship EGL/Qt deps are unaffected.

Checklist

  • My code follows the project's style guidelines
  • 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 (subset 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 Apr 18, 2026
@oldrepublicwizard
oldrepublicwizard merged commit 57141fc into master Apr 28, 2026
5 of 9 checks passed
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