mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-12-02 01:48:08 +09:00
## Summary - Fix IndexError in `_extend_anchors_into_single_word_gaps` when `ref_texts_clean` and `ref_words` have different word counts due to `clean_text()` normalization - Adds production fixture regression test from crashing job `b7e8c96d` (Bằng Kiều - Dẫu có lỗi lầm) ## Root Cause `ref_texts_clean` is built by joining words → `clean_text()` → `split()`, which can produce a **different word count** than the raw `ref_words` Word objects list. For Spotify in the crashing job: `ref_texts_clean` had 599 words, `ref_words` had 528. Anchor `reference_positions` computed against the 599-word list were used to index the 528-word list. ## Changes - `anchor_sequence.py`: Add `< len(ref_words[source])` bounds check in both `_apply_forward_extension` and `_apply_backward_extension` - `test_anchor_gap_extension_bounds.py`: 4 regression tests (production fixture + synthetic bounds tests) - `anchor_crash_b7e8c96d.json`: Sanitized production fixture (49 anchors, 526 words) - `LESSONS-LEARNED.md`: Document text normalization word count mismatch gotcha - Version bump: 0.153.4 → 0.153.5 ## Testing - [x] 33 anchor gap extension tests pass (29 existing + 4 new) - [x] Full unit suite: 1146 tests pass - [ ] After deploy: retry job `b7e8c96d` ## Review - [x] CodeRabbit CLI review completed locally (1 finding fixed: sanitized copyrighted lyrics) @coderabbitai ignore --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Unit Tests for KaraokePrep
This directory contains unit tests for the KaraokePrep class.
Test Files
The tests are organized into the following files:
test_initialization.py: Tests for initialization and basic functionalitytest_file_operations.py: Tests for file operations (copy, download, convert)test_metadata.py: Tests for metadata extraction and parsingtest_lyrics.py: Tests for lyrics processingtest_audio.py: Tests for audio processing and separationtest_video.py: Tests for video creation and processingtest_async.py: Tests for async methods
Running the Tests
To run the tests, you need to have the test dependencies installed:
pip install -r requirements-test.txt
Then you can run the tests with:
python run_tests.py
This will run all the tests and generate a coverage report.
Checking Test Files
If you want to check if the test files are valid Python code without running the tests, you can use:
python check_tests.py
This will check if all the test files can be imported without errors.
Test Coverage
The tests aim to cover all the functionality of the KaraokePrep class. The coverage report will show you which parts of the code are covered by the tests.