You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3.3 KiB
3.3 KiB
title: Test assertions failed after extracting SVD_THEMES to separate module
date: 2026-04-04
category: docs/solutions/test-failures/
module: Stemwijzer Data Analysis
problem_type: test_failure
component: explorer
symptoms:
- "test_display_label_for_modal" assertion failed with "EU-integratie" not found
- "test_get_svd_label_returns_correct_label" assertion failed with "Nationalisme" not found
- Tests expected old fallback labels but SVD_THEMES had updated values
root_cause: test_failure
resolution_type: test_fix
severity: medium
tags: [svd, test-assertions, refactoring, constants]
affected_files:
- tests/test_axis_label_fallback.py
- tests/test_svd_labels.py
- analysis/config.py
Test assertions failed after extracting SVD_THEMES to separate module
Problem
After extracting SVD_THEMES constant from explorer.py to analysis/config.py, tests failed because they hardcoded assertions for old label text.
Symptoms
test_display_label_for_modal: expected"EU-integratie" in x_label or "Nationalisme" in x_labeltest_get_svd_label_returns_correct_label: expected"EU-integratie" in label1test_manifest_loads: manifest.yaml hadcategories:key instead offiles:
What Didn't Work
- Investigating
get_svd_label()function — it correctly returned values fromSVD_THEMES - Checking import chain — no circular import issues
- The problem was purely that test assertions hardcoded OLD expected label values
Solution
Updated test assertions to match the current SVD_THEMES values:
tests/test_axis_label_fallback.py:
# Before (incorrect)
assert "EU-integratie" in x_label or "Nationalisme" in x_label
assert "Populistisch" in y_label or "Institutioneel" in y_label
# After (correct)
assert "Rechts kabinetsbeleid" in x_label or "links oppositiebeleid" in x_label
assert "PVV/FVD-populisme" in y_label or "mainstream-partijen" in y_label
tests/test_svd_labels.py:
# Before (incorrect)
assert "EU-integratie" in label1 or "Nationalisme" in label1
# After (correct)
assert "Rechts kabinetsbeleid" in label1 or "links oppositiebeleid" in label1
Fix manifest.yaml:
# Before (incorrect)
categories:
# After (correct)
files:
Why This Works
The tests were asserting on hardcoded string values that no longer matched the actual SVD_THEMES content. After updating the assertions to check for current label text, tests pass because they correctly verify the actual values returned.
Prevention
- Audit tests when extracting constants — When extracting constants to separate modules, grep for all test references to those constants and update assertions
- Use flexible assertions — Prefer
inchecks over exact matches when testing label text, or better yet, import the constant directly in tests and assert equality - Update manifest tests early — When changing YAML structure in config files, check for corresponding manifest/schema tests
Related Issues
analysis/config.py— ContainsSVD_THEMES(extracted fromexplorer.py)analysis/svd_labels.py— UsesSVD_THEMESvia runtime import fromexplorer.pydocs/solutions/logic-errors/svd-component-labels-mismatch.md— Background on why SVD labels were updated from semantic to voting-pattern based