refactor: remove skipped test and unused reference update utility
- Remove test_reference_image_update_utility that was always skipped - Remove --update-references option and make target that were unused - Simplify reference image update process to manual deletion + test rerun - Clean up documentation to reflect simpler approach All tests now run without skipping. Reference updates are handled by deleting old images and letting tests auto-generate new ones. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
5
Makefile
5
Makefile
@@ -87,10 +87,6 @@ pytest-cov:
|
||||
@pip3 show pytest-cov >/dev/null 2>&1 || { echo "Installing test dependencies..."; pip3 install -r requirements.txt; }
|
||||
python3 -m pytest tests/ -v --cov=src --cov-report=html --cov-report=term
|
||||
|
||||
# Update visual test reference images
|
||||
update-references:
|
||||
@echo "Updating visual test references..."
|
||||
python3 -m pytest tests/test_visual.py::TestVisualRegression::test_reference_image_update_utility --update-references -v
|
||||
|
||||
# Show help
|
||||
help:
|
||||
@@ -108,7 +104,6 @@ help:
|
||||
@echo " make pytest-fast Run fast tests only (skip slow ones)"
|
||||
@echo " make pytest-visual Run visual regression tests only"
|
||||
@echo " make pytest-cov Run tests with coverage report"
|
||||
@echo " make update-references Update visual test reference images"
|
||||
@echo ""
|
||||
@echo "Setup targets:"
|
||||
@echo " make install Install dependencies (macOS)"
|
||||
|
||||
@@ -41,13 +41,7 @@ The visual tests generate flashcard images and compare them against reference im
|
||||
|
||||
### Updating References
|
||||
|
||||
When you make intentional visual changes:
|
||||
|
||||
```bash
|
||||
make update-references
|
||||
```
|
||||
|
||||
This regenerates the reference images in `tests/references/`.
|
||||
When you make intentional visual changes, manually delete the old reference images in `tests/references/` and run the visual tests. They will automatically create new reference images on first run.
|
||||
|
||||
### How Visual Tests Work
|
||||
|
||||
|
||||
@@ -50,9 +50,3 @@ def reference_images_dir(project_root):
|
||||
ref_dir.mkdir(exist_ok=True)
|
||||
return ref_dir
|
||||
|
||||
def pytest_addoption(parser):
|
||||
"""Add custom pytest options."""
|
||||
parser.addoption(
|
||||
"--update-references", action="store_true", default=False,
|
||||
help="Update reference images for visual tests"
|
||||
)
|
||||
@@ -186,45 +186,4 @@ class TestVisualRegression:
|
||||
except FileNotFoundError:
|
||||
pytest.skip("Typst not available for PDF compilation")
|
||||
|
||||
def test_reference_image_update_utility(self, request, temp_dir, sample_config, reference_images_dir):
|
||||
"""Utility to regenerate reference images when needed."""
|
||||
# This test can be run manually to update references
|
||||
# Skip in normal test runs
|
||||
if not request.config.getoption("--update-references", default=False):
|
||||
pytest.skip("Reference update not requested")
|
||||
|
||||
# Generate fresh reference images
|
||||
test_cases = [
|
||||
(7, 'basic'),
|
||||
(23, 'multidigit'),
|
||||
(0, 'zero')
|
||||
]
|
||||
|
||||
for number, name in test_cases:
|
||||
config = {
|
||||
**sample_config,
|
||||
'card_width': '2in',
|
||||
'card_height': '1.4in',
|
||||
'transparent': False
|
||||
}
|
||||
|
||||
output_dir = temp_dir / f'ref_{name}'
|
||||
generate_cards_direct(
|
||||
[number], config, output_dir,
|
||||
format='png', dpi=150,
|
||||
separate_fronts_backs=True
|
||||
)
|
||||
|
||||
# Copy to references
|
||||
front_src = output_dir / 'fronts' / 'card_000.png'
|
||||
back_src = output_dir / 'backs' / 'card_000.png'
|
||||
front_dst = reference_images_dir / f'card_{number}_front.png'
|
||||
back_dst = reference_images_dir / f'card_{number}_back.png'
|
||||
|
||||
if front_src.exists():
|
||||
front_src.replace(front_dst)
|
||||
print(f"Updated reference: {front_dst}")
|
||||
if back_src.exists():
|
||||
back_src.replace(back_dst)
|
||||
print(f"Updated reference: {back_dst}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user