Skip to content

test(tslpatcher): strengthen merge-tslpatcher conflict artifact coverage - #182

Merged
oldrepublicwizard merged 1 commit into
masterfrom
cursor/missing-test-coverage-d889
Apr 28, 2026
Merged

test(tslpatcher): strengthen merge-tslpatcher conflict artifact coverage#182
oldrepublicwizard merged 1 commit into
masterfrom
cursor/missing-test-coverage-d889

Conversation

@cursor

@cursor cursor Bot commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Description

Adds regression tests for --merge-tslpatcher conflict artifact mode when no custom output directory is set, and for _normalize_merge_conflict_policy so invalid or missing policy values safely default to mod-a.

Type of Change

  • ✅ Test addition or update

Package(s) Affected

  • PyKotor (core library)

Changes Made

  • test_merge_tslpatcher_artifact_default_output_dir_and_report: Asserts artifacts land in <tslpatchdata>/merge_conflicts/, exit code 1, no changes.ini, and conflicts.json contains expected keys, non-empty conflicts, and on-disk artifact paths.
  • test_normalize_merge_conflict_policy_defaults_unknown: Locks behavior of _normalize_merge_conflict_policy for None, empty string, unknown strings, and valid policies.

Risky behavior now covered

  • Default artifact output path: Prevents regressions where merge conflicts in artifact mode write to the wrong directory or skip README.txt / conflicts.json.
  • Conflict report shape: Ensures conflicts.json remains parseable and includes conflict entries and artifact paths (downstream tooling and triage).
  • Policy normalization: Unknown CLI/config values must not propagate as invalid policies; they must fall back to mod-a (consistent with run_merge_tslpatcher_workflow).

Test files added/updated

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

Why these tests materially reduce regression risk

The prior artifact test only covered a custom merge_conflict_output_path. The new test covers the default branch in _write_merge_conflict_artifacts, which users rely on when they omit --merge-conflict-output. Policy normalization had no direct tests; a bad default could silently change conflict resolution across merges.

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

PYTHONPATH=Libraries/PyKotor/src:Libraries/Utility/src QT_QPA_PLATFORM=offscreen python3 -m pytest \
  Libraries/PyKotor/tests/tslpatcher/diff/test_diff_tslpatcher.py::TestTSLPatcherFromDiff::test_merge_tslpatcher_artifact_default_output_dir_and_report \
  Libraries/PyKotor/tests/tslpatcher/diff/test_diff_tslpatcher.py::TestTSLPatcherFromDiff::test_normalize_merge_conflict_policy_defaults_unknown \
  --import-mode=importlib -m "not gui and not slow" --timeout=120
# 2 passed

Note: uv was not available in this automation environment; tests were run with python3 -m pytest after pip install of the local Libraries/PyKotor package and test deps.

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 merge-tslpatcher / diff conflict artifact behavior (recent fix(diff): add conflict artifacts and unique ini sections).

Additional Notes

Tests are deterministic (temp dirs, synthetic DLG + fake install) and do not depend on game assets.

Open in Web View Automation 

…ormalization

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 21, 2026
@oldrepublicwizard
oldrepublicwizard merged commit b06f91a into master Apr 28, 2026
32 of 42 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