Files
thechart/scripts/test_theme_changing.py
William Valentin a521ed6e9a
Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled
Add quick test runner and enhance run_tests script
- Introduced `quick_test.py` for running specific test categories (unit, integration, theme, all).
- Updated `run_tests.py` to improve test execution and reporting, including coverage.
- Removed outdated test scripts for keyboard shortcuts, menu theming, note saving, and entry updating.
- Added new test script `test_theme_changing.py` to verify theme changing functionality.
- Consolidated integration tests into `test_integration.py` for comprehensive testing of TheChart application.
- Updated theme manager to ensure color retrieval works correctly.
- Modified test constants to import from the correct module path.
2025-08-05 15:09:13 -07:00

58 lines
1.7 KiB
Python

#!/usr/bin/env python3
"""Test script to verify theme changing functionality works without errors."""
import sys
import tkinter as tk
from pathlib import Path
from init import logger
from theme_manager import ThemeManager
# Add src directory to Python path
src_path = Path(__file__).parent.parent / "src"
sys.path.insert(0, str(src_path))
def test_theme_changes():
"""Test changing between different themes to ensure no errors occur."""
print("Testing theme changing functionality...")
# Create a test tkinter window
root = tk.Tk()
root.withdraw() # Hide the window
# Initialize theme manager
theme_manager = ThemeManager(root, logger)
# Test all available themes
available_themes = theme_manager.get_available_themes()
print(f"Available themes: {available_themes}")
for theme in available_themes:
print(f"Testing theme: {theme}")
try:
success = theme_manager.apply_theme(theme)
if success:
print(f"{theme} applied successfully")
# Test getting theme colors (this is where the error was occurring)
colors = theme_manager.get_theme_colors()
print(f" ✓ Theme colors retrieved: {list(colors.keys())}")
# Test getting menu colors
menu_colors = theme_manager.get_menu_colors()
print(f" ✓ Menu colors retrieved: {list(menu_colors.keys())}")
else:
print(f" ✗ Failed to apply {theme}")
except Exception as e:
print(f" ✗ Error with {theme}: {e}")
# Clean up
root.destroy()
print("Theme testing completed!")
if __name__ == "__main__":
test_theme_changes()