~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
Add comprehensive theme system tests
LearningCircuit2dc010e3f09c
diff --git a/tests/theme_tests/test_theme_system.py b/tests/theme_tests/test_theme_system.pyindex 1bf8b845ad..fd20a26ccd 100644--- a/tests/theme_tests/test_theme_system.py+++ b/tests/theme_tests/test_theme_system.py@@ -551,7 +551,6 @@ class TestComponentCoverage:"styles.css","collections.css","settings.css",- "news-enhanced.css",]REQUIRED_VAR_USAGE = [@@ -1072,5 +1071,820 @@ class TestColorConsistency:)+class TestShadowTheming:+ """Test that box shadows use theme-appropriate colors."""++ def test_shadows_use_rgba_variables(self):+ """Box shadows should use rgba with CSS variables, not hardcoded colors."""+ issues = []+ # Pattern for box-shadow with hardcoded rgba+ shadow_pattern = re.compile(+ r"box-shadow:\s*[^;]*rgba\s*\(\s*\d+\s*,\s*\d+\s*,\s*\d+",+ re.IGNORECASE,+ )++ for css_file in CSS_DIR.rglob("*.css"):+ if css_file.name == "themes.css":+ continue++ content = css_file.read_text()+ for i, line in enumerate(content.split("\n"), 1):+ # Skip if using CSS variable for rgba+ if "rgba(var(--" in line:+ continue+ # Allow black shadows (common and intentional)+ if "rgba(0, 0, 0" in line or "rgba(0,0,0" in line:+ continue+ if shadow_pattern.search(line):+ issues.append(f"{css_file.name}:{i}")++ if len(issues) > 5:+ pytest.fail(+ f"Found {len(issues)} shadows with non-black hardcoded colors:\n"+ + "\n".join(issues[:10])+ )++ def test_no_hardcoded_shadow_colors_in_js(self):+ """JavaScript should not set hardcoded shadow colors."""+ issues = []+ shadow_pattern = re.compile(+ r"boxShadow\s*=\s*['\"].*?#[0-9a-fA-F]{3,8}", re.IGNORECASE+ )++ for js_file in JS_DIR.rglob("*.js"):+ content = js_file.read_text()+ for i, line in enumerate(content.split("\n"), 1):+ if shadow_pattern.search(line):+ issues.append(f"{js_file.name}:{i}")++ if issues:+ pytest.fail(+ f"Found {len(issues)} hardcoded shadows in JS:\n"+ + "\n".join(issues[:10])+ )+++class TestFocusStateTheming:+ """Test that focus states use theme colors."""++ def test_focus_outline_uses_theme_colors(self):+ """Focus outlines should use accent colors from theme."""+ focus_uses_var = False+ focus_pattern = re.compile(r":focus[^{]*\{[^}]*outline", re.DOTALL)++ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ if focus_pattern.search(content):+ if "var(--accent-" in content or "var(--border-" in content:+ focus_uses_var = True+ break++ assert focus_uses_var, (+ "Focus states should use theme variables for outline colors"+ )++ def test_focus_visible_defined(self):+ """Should have :focus-visible styles for keyboard navigation."""+ focus_visible_found = False++ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ if ":focus-visible" in content:+ focus_visible_found = True+ break++ assert focus_visible_found, (+ "Should define :focus-visible styles for accessibility"+ )+++class TestFormElementTheming:+ """Test that form elements use theme colors."""++ def test_input_uses_theme_colors(self):+ """Input elements should use theme background and text colors."""+ input_pattern = re.compile(+ r"input\s*(?:\[[^\]]*\])?\s*\{[^}]+\}", re.DOTALL+ )++ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ matches = input_pattern.findall(content)+ for match in matches:+ # Should use theme vars, not hardcoded colors+ if "background" in match and "#" in match:+ if "var(--" not in match:+ pytest.fail(+ f"Input styles in {css_file.name} have hardcoded bg"+ )++ def test_select_uses_theme_colors(self):+ """Select elements should use theme colors."""+ for css_file in CSS_DIR.rglob("*.css"):+ if css_file.name in ["custom_dropdown.css", "settings.css"]:+ content = css_file.read_text()+ if "select" in content.lower():+ assert "var(--" in content, (+ f"{css_file.name} should use theme variables for selects"+ )+ break++ def test_placeholder_color_themed(self):+ """Placeholder text should use theme muted color."""+ placeholder_found = False++ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ if (+ "::placeholder" in content+ or "::-webkit-input-placeholder" in content+ ):+ placeholder_found = True+ if (+ "var(--text-muted)" in content+ or "var(--text-secondary)" in content+ ):+ return # Good - using theme variable++ if placeholder_found:+ # Placeholder exists but might not use theme vars - just warn+ pass+++class TestButtonTheming:+ """Test that buttons use theme colors appropriately."""++ def test_primary_button_uses_accent(self):+ """Primary buttons should use accent colors."""+ primary_btn_uses_accent = False++ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ # Look for primary button definitions+ if ".btn-primary" in content or ".ldr-btn-primary" in content:+ if "var(--accent-primary)" in content:+ primary_btn_uses_accent = True+ break++ assert primary_btn_uses_accent, (+ "Primary buttons should use --accent-primary"+ )++ def test_button_hover_states_themed(self):+ """Button hover states should use theme colors."""+ hover_pattern = re.compile(r"\.btn[^{]*:hover\s*\{([^}]+)\}", re.DOTALL)++ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ matches = hover_pattern.findall(content)+ for match in matches:+ if "#" in match and "var(--" not in match:+ # Has hardcoded color without CSS variable+ # Check if it's a brand exception+ if not any(+ brand.lower() in match.lower()+ for brand in BRAND_COLOR_EXCEPTIONS+ ):+ pytest.fail(+ f"Button hover in {css_file.name} has hardcoded color"+ )+++class TestModalTheming:+ """Test that modals and dialogs use theme colors."""++ def test_modal_backdrop_themed(self):+ """Modal backdrops should use theme-compatible colors."""+ modal_patterns = [+ "modal-backdrop",+ "ldr-modal",+ ".modal",+ "dialog",+ ]++ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ for pattern in modal_patterns:+ if pattern in content:+ # Check if backdrop uses rgba with variables+ if "backdrop" in content.lower():+ if (+ "rgba(var(--" in content+ or "rgba(0, 0, 0" in content+ ):+ return # Good+ # Modal may be defined elsewhere or in templates+ pass++ def test_modal_content_uses_theme_bg(self):+ """Modal content should use theme background colors."""+ for template in TEMPLATES_DIR.rglob("*.html"):+ if "modal" in template.name.lower():+ content = template.read_text()+ # Should not have hardcoded background colors+ if (+ "background-color: #" in content+ or "background:#" in content+ ):+ if "var(--" not in content:+ pytest.fail(+ f"Modal {template.name} has hardcoded background"+ )+++class TestLinkTheming:+ """Test that links use theme colors."""++ def test_links_use_accent_colors(self):+ """Links should use accent or dedicated link colors."""+ link_uses_theme = False++ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ # Find anchor styles+ if re.search(r"\ba\s*\{", content) or re.search(+ r"\ba:link", content+ ):+ if "var(--accent-" in content or "var(--link-" in content:+ link_uses_theme = True+ break++ assert link_uses_theme, "Links should use theme accent or link colors"++ def test_visited_links_themed(self):+ """Visited links should be styled with theme awareness."""+ visited_found = False++ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ if ":visited" in content:+ visited_found = True+ break++ # Not all sites style visited links, so just note if found+ if visited_found:+ pass # Good that it's considered+++class TestScrollbarTheming:+ """Test scrollbar theming for webkit browsers."""++ def test_scrollbar_uses_theme_colors(self):+ """Custom scrollbars should use theme colors."""+ scrollbar_uses_theme = False++ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ if "::-webkit-scrollbar" in content:+ # Check if it uses theme variables+ if "var(--" in content:+ scrollbar_uses_theme = True+ break++ # Scrollbar styling is optional but should use theme vars if present+ if not scrollbar_uses_theme:+ # Check if any scrollbar styling exists+ for css_file in CSS_DIR.rglob("*.css"):+ if "::-webkit-scrollbar" in css_file.read_text():+ pytest.fail(+ "Scrollbar styles found but not using theme variables"+ )+++class TestTransitionAndAnimation:+ """Test that color transitions work with theme switching."""++ def test_theme_transition_defined(self):+ """Should have smooth transitions for theme changes."""+ transition_found = False++ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ # Look for color/background transitions+ if re.search(+ r"transition[^;]*(?:color|background|border)[^;]*;", content+ ):+ transition_found = True+ break++ assert transition_found, (+ "Should have CSS transitions for smooth theme switching"+ )++ def test_no_color_flash_on_load(self):+ """Theme should be applied before content is visible."""+ base_html = TEMPLATES_DIR / "base.html"+ if not base_html.exists():+ pytest.skip("base.html not found")++ content = base_html.read_text()++ # Theme initialization should happen early (in head or early body)+ head_content = (+ content.split("</head>")[0] if "</head>" in content else ""+ )++ # Should have theme detection/setting in head+ theme_in_head = (+ "data-theme" in head_content+ or "theme" in head_content.lower()+ or "localStorage" in head_content+ )++ assert theme_in_head, (+ "Theme should be initialized in <head> to prevent flash"+ )+++class TestCodeBlockTheming:+ """Test that code blocks and pre elements use theme colors."""++ def test_code_blocks_themed(self):+ """Code blocks should use theme-appropriate colors."""+ code_themed = False++ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ if re.search(r"\bcode\b|\bpre\b", content):+ if "var(--" in content:+ code_themed = True+ break++ assert code_themed, "Code blocks should use theme variables"+++class TestTableTheming:+ """Test that tables use theme colors."""++ def test_table_borders_themed(self):+ """Table borders should use theme border color."""+ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ if re.search(r"\btable\b|\bth\b|\btd\b", content):+ if "border" in content:+ if (+ "var(--border-color)" in content+ or "var(--bg-" in content+ ):+ return # Good++ def test_table_striping_themed(self):+ """Table row striping should use theme colors."""+ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ # Look for nth-child or stripe patterns+ if "nth-child" in content and "tr" in content:+ if "var(--" in content:+ return # Good - using theme variables+++class TestLoadingStateTheming:+ """Test that loading states use theme colors."""++ def test_spinner_uses_theme_colors(self):+ """Loading spinners should use theme accent color."""+ spinner_patterns = ["spinner", "loading", "loader"]+ spinner_themed = False++ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ for pattern in spinner_patterns:+ if pattern in content.lower():+ if "var(--accent-" in content:+ spinner_themed = True+ break+ if spinner_themed:+ break++ assert spinner_themed, "Spinners should use theme accent colors"++ def test_skeleton_loaders_themed(self):+ """Skeleton loaders should use theme background variants."""+ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ if "skeleton" in content.lower():+ if "var(--bg-" in content:+ return # Good+++class TestTooltipTheming:+ """Test that tooltips use theme colors."""++ def test_tooltips_use_theme_colors(self):+ """Tooltips should use theme-aware colors."""+ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ if "tooltip" in content.lower():+ if "var(--" in content:+ return # Good - using theme vars+ # Tooltips might not exist, which is fine+++class TestBadgeAndTagTheming:+ """Test that badges and tags use theme colors."""++ def test_badges_use_semantic_colors(self):+ """Badges should use theme semantic colors."""+ badge_patterns = ["badge", "tag", "chip", "label"]++ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ for pattern in badge_patterns:+ if (+ f".{pattern}" in content.lower()+ or f".ldr-{pattern}" in content+ ):+ if (+ "var(--success-" in content+ or "var(--warning-" in content+ or "var(--error-" in content+ or "var(--accent-" in content+ ):+ return # Good+++class TestAlertTheming:+ """Test that alerts use theme semantic colors."""++ def test_alert_success_uses_success_color(self):+ """Success alerts should use --success-color."""+ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ if ".alert-success" in content or ".ldr-alert-success" in content:+ if (+ "var(--success-color)" in content+ or "var(--success-color-rgb)" in content+ ):+ return+ # Might not have alert component++ def test_alert_error_uses_error_color(self):+ """Error alerts should use --error-color."""+ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ if (+ ".alert-error" in content+ or ".alert-danger" in content+ or ".ldr-alert-error" in content+ ):+ if (+ "var(--error-color)" in content+ or "var(--error-color-rgb)" in content+ ):+ return+++class TestProgressBarTheming:+ """Test that progress bars use theme colors."""++ def test_progress_bar_uses_accent(self):+ """Progress bars should use accent color."""+ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ if "progress" in content.lower():+ if "var(--accent-" in content:+ return # Good++ def test_progress_track_uses_theme_bg(self):+ """Progress bar tracks should use theme background."""+ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ if "progress" in content.lower() and "track" in content.lower():+ if "var(--bg-" in content:+ return+++class TestNavTheming:+ """Test that navigation uses theme colors."""++ def test_nav_uses_theme_colors(self):+ """Navigation should use theme colors."""+ nav_themed = False++ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ if ".nav" in content or "nav " in content:+ if "var(--" in content:+ nav_themed = True+ break++ assert nav_themed, "Navigation should use theme variables"++ def test_active_nav_item_uses_accent(self):+ """Active nav items should use accent color."""+ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ if ".nav" in content and ".active" in content:+ if "var(--accent-" in content:+ return+++class TestCardTheming:+ """Test that cards use theme colors."""++ def test_cards_use_theme_bg(self):+ """Cards should use theme background colors."""+ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ if ".card" in content or ".ldr-card" in content:+ if "var(--bg-" in content:+ return # Good++ def test_card_borders_themed(self):+ """Card borders should use theme border color."""+ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ if ".card" in content:+ if "border" in content and "var(--border-color)" in content:+ return+++class TestHeaderFooterTheming:+ """Test that header and footer use theme colors."""++ def test_header_uses_theme_colors(self):+ """Header should use theme colors."""+ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ if "header" in content.lower() or ".navbar" in content:+ if "var(--" in content:+ return++ def test_footer_uses_theme_colors(self):+ """Footer should use theme colors."""+ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ if "footer" in content.lower():+ if "var(--" in content:+ return+++class TestSelectionTheming:+ """Test text selection uses theme colors."""++ def test_selection_color_themed(self):+ """Text selection should use theme-aware colors."""+ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ if "::selection" in content:+ if "var(--" in content:+ return # Good - using theme vars+++class TestHighContrastCompliance:+ """Test high contrast theme meets accessibility requirements."""++ @pytest.fixture+ def themes_css_content(self):+ """Load themes.css content."""+ return (CSS_DIR / "themes.css").read_text()++ def _get_luminance(self, hex_color: str) -> float:+ """Calculate relative luminance."""+ r = int(hex_color[1:3], 16) / 255+ g = int(hex_color[3:5], 16) / 255+ b = int(hex_color[5:7], 16) / 255+ return 0.299 * r + 0.587 * g + 0.114 * b++ def _contrast_ratio(self, l1: float, l2: float) -> float:+ """Calculate contrast ratio."""+ lighter = max(l1, l2)+ darker = min(l1, l2)+ return (lighter + 0.05) / (darker + 0.05)++ def _extract_theme_color(+ self, themes_css_content: str, theme: str, var_name: str+ ) -> str | None:+ """Extract a color variable from a theme."""+ if theme == "dark":+ pattern = rf":root[^{{]*\{{[^}}]*{var_name}:\s*(#[0-9a-fA-F]{{6}})"+ else:+ pattern = rf'\[data-theme="{theme}"\][^{{]*\{{[^}}]*{var_name}:\s*(#[0-9a-fA-F]{{6}})'+ match = re.search(pattern, themes_css_content, re.DOTALL)+ return match.group(1) if match else None++ def test_high_contrast_has_higher_ratio(self, themes_css_content):+ """High contrast theme should have higher contrast than regular dark."""+ # Get dark theme contrast+ dark_bg = self._extract_theme_color(+ themes_css_content, "dark", "--bg-primary"+ )+ dark_text = self._extract_theme_color(+ themes_css_content, "dark", "--text-primary"+ )++ # Get high-contrast theme contrast+ hc_bg = self._extract_theme_color(+ themes_css_content, "high-contrast", "--bg-primary"+ )+ hc_text = self._extract_theme_color(+ themes_css_content, "high-contrast", "--text-primary"+ )++ if not all([dark_bg, dark_text, hc_bg, hc_text]):+ pytest.skip("Could not extract colors for comparison")++ dark_ratio = self._contrast_ratio(+ self._get_luminance(dark_bg), self._get_luminance(dark_text)+ )+ hc_ratio = self._contrast_ratio(+ self._get_luminance(hc_bg), self._get_luminance(hc_text)+ )++ assert hc_ratio >= dark_ratio, (+ f"High contrast ({hc_ratio:.2f}) should have >= contrast than dark ({dark_ratio:.2f})"+ )++ def test_high_contrast_meets_aaa(self, themes_css_content):+ """High contrast theme should meet WCAG AAA (7:1) for text."""+ hc_bg = self._extract_theme_color(+ themes_css_content, "high-contrast", "--bg-primary"+ )+ hc_text = self._extract_theme_color(+ themes_css_content, "high-contrast", "--text-primary"+ )++ if not hc_bg or not hc_text:+ pytest.skip("Could not extract high-contrast colors")++ ratio = self._contrast_ratio(+ self._get_luminance(hc_bg), self._get_luminance(hc_text)+ )++ assert ratio >= 7.0, (+ f"High contrast should meet WCAG AAA (7:1), got {ratio:.2f}"+ )+++class TestThemeLocalStorage:+ """Test theme persistence via localStorage."""++ def test_theme_saved_to_localstorage(self):+ """JavaScript should save theme preference to localStorage."""+ localstorage_theme_found = False++ for js_file in JS_DIR.rglob("*.js"):+ content = js_file.read_text()+ if "localStorage" in content and "theme" in content.lower():+ localstorage_theme_found = True+ break++ assert localstorage_theme_found, (+ "Theme should be saved to localStorage for persistence"+ )++ def test_theme_loaded_from_localstorage(self):+ """Theme should be loaded from localStorage on page load."""+ load_found = False++ for js_file in JS_DIR.rglob("*.js"):+ content = js_file.read_text()+ if "localStorage.getItem" in content and "theme" in content.lower():+ load_found = True+ break++ # Also check templates+ if not load_found:+ for template in TEMPLATES_DIR.rglob("*.html"):+ content = template.read_text()+ if "localStorage" in content and "theme" in content.lower():+ load_found = True+ break++ assert load_found, "Theme should be loaded from localStorage on init"+++class TestThemeCSSSyntax:+ """Test CSS syntax is valid in theme definitions."""++ @pytest.fixture+ def themes_css_content(self):+ """Load themes.css content."""+ return (CSS_DIR / "themes.css").read_text()++ def test_no_unclosed_braces(self, themes_css_content):+ """CSS should have balanced braces."""+ open_braces = themes_css_content.count("{")+ close_braces = themes_css_content.count("}")++ assert open_braces == close_braces, (+ f"Unbalanced braces: {open_braces} open, {close_braces} close"+ )++ def test_no_duplicate_theme_definitions(self, themes_css_content):+ """Each theme's root definition should only appear once.++ Note: Additional selectors like [data-theme="x"] a { } for element+ overrides are allowed and expected - we only check for duplicate+ root theme variable definitions (selectors followed directly by {).+ """+ # Pattern for root theme definitions only (not element-specific like+ # [data-theme="x"] a or [data-theme="x"] button)+ # This matches [data-theme="x"] { but not [data-theme="x"] a {+ theme_pattern = re.compile(r'\[data-theme="([^"]+)"\]\s*\{')+ themes = theme_pattern.findall(themes_css_content)++ # Count occurrences+ from collections import Counter++ counts = Counter(themes)++ duplicates = [t for t, c in counts.items() if c > 1]+ assert not duplicates, f"Duplicate root theme definitions: {duplicates}"++ def test_variables_have_values(self, themes_css_content):+ """CSS variables should have values, not be empty."""+ empty_var_pattern = re.compile(r"--[\w-]+:\s*;")+ empty_vars = empty_var_pattern.findall(themes_css_content)++ assert not empty_vars, f"Empty variable definitions found: {empty_vars}"++ def test_hex_colors_are_valid(self, themes_css_content):+ """All hex colors should be valid 3, 6, or 8 character hex."""+ hex_pattern = re.compile(r"#([0-9a-fA-F]+)\b")++ for match in hex_pattern.finditer(themes_css_content):+ hex_value = match.group(1)+ assert len(hex_value) in [3, 6, 8], (+ f"Invalid hex color length: #{hex_value} ({len(hex_value)} chars)"+ )+++class TestChartTheming:+ """Test that chart/visualization colors are theme-aware."""++ def test_chart_colors_documented(self):+ """Chart colors should be documented or use theme vars."""+ chart_files = []+ for js_file in JS_DIR.rglob("*.js"):+ if (+ "chart" in js_file.name.lower()+ or "details" in js_file.name.lower()+ ):+ chart_files.append(js_file)++ # Charts often need specific colors for data visualization+ # Just verify they exist and have some color handling+ for chart_file in chart_files:+ content = chart_file.read_text()+ if "Chart" in content or "chart" in content:+ # Good - chart code exists+ return+++class TestMediaQueryTheming:+ """Test media query handling for theme preferences."""++ def test_prefers_color_scheme_support(self):+ """Should support prefers-color-scheme media query."""+ prefers_found = False++ # Check CSS+ for css_file in CSS_DIR.rglob("*.css"):+ content = css_file.read_text()+ if "prefers-color-scheme" in content:+ prefers_found = True+ break++ # Check JS+ if not prefers_found:+ for js_file in JS_DIR.rglob("*.js"):+ content = js_file.read_text()+ if "prefers-color-scheme" in content:+ prefers_found = True+ break++ assert prefers_found, (+ "Should support prefers-color-scheme for system theme detection"+ )+++class TestResponsiveTheming:+ """Test that themes work across different screen sizes."""++ def test_no_fixed_color_in_media_queries(self):+ """Media queries should not override with hardcoded colors."""+ issues = []+ media_pattern = re.compile(+ r"@media[^{]*\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}", re.DOTALL+ )++ for css_file in CSS_DIR.rglob("*.css"):+ if css_file.name == "themes.css":+ continue++ content = css_file.read_text()+ for match in media_pattern.finditer(content):+ media_content = match.group(1)+ # Check for hardcoded colors+ if re.search(r":\s*#[0-9a-fA-F]{3,8}\s*;", media_content):+ if "var(--" not in media_content:+ issues.append(css_file.name)+ break++ if len(issues) > 3:+ pytest.fail(f"Media queries with hardcoded colors: {issues[:5]}")++if __name__ == "__main__":pytest.main([__file__, "-v"])