refactor: Update exception handling parameters in context managers for consistency

This commit is contained in:
William Valentin
2025-08-08 17:44:50 -07:00
parent 9e107f6125
commit 87b59cd64a
6 changed files with 14 additions and 8 deletions
+1 -1
View File
@@ -245,7 +245,7 @@ class OperationTimer:
self.start_time = time.time() self.start_time = time.time()
return self return self
def __exit__(self, exc_type, exc_val, exc_tb): def __exit__(self, _exc_type, _exc_val, _exc_tb):
"""End timing and check for performance issues.""" """End timing and check for performance issues."""
import time import time
+9 -3
View File
@@ -11,9 +11,15 @@ def root_window():
@pytest.fixture @pytest.fixture
def ui_manager(root_window): def ui_manager(root_window):
class DummyLogger: class DummyLogger:
def debug(self, *a, **k): pass def debug(self, *_args, **_kwargs):
def warning(self, *a, **k): pass pass
def error(self, *a, **k): pass
def warning(self, *_args, **_kwargs):
pass
def error(self, *_args, **_kwargs):
pass
return UIManager(root_window, DummyLogger()) return UIManager(root_window, DummyLogger())
def test_parse_dose_history_for_saving_bullet_and_delete(ui_manager): def test_parse_dose_history_for_saving_bullet_and_delete(ui_manager):
+1 -1
View File
@@ -152,7 +152,7 @@ class TestExportManager:
@patch('matplotlib.pyplot.draw') @patch('matplotlib.pyplot.draw')
@patch('matplotlib.pyplot.pause') @patch('matplotlib.pyplot.pause')
def test_save_graph_as_image_success(self, mock_pause, mock_draw, export_manager): def test_save_graph_as_image_success(self, _mock_pause, _mock_draw, export_manager):
"""Test successful graph image saving.""" """Test successful graph image saving."""
with tempfile.TemporaryDirectory() as temp_dir: with tempfile.TemporaryDirectory() as temp_dir:
temp_path = Path(temp_dir) temp_path = Path(temp_dir)
+1 -1
View File
@@ -98,7 +98,7 @@ def test_load_preset_applies_filters(widget, monkeypatch):
w.preset_var.set("MyPreset") w.preset_var.set("MyPreset")
# Suppress any warnings # Suppress any warnings
monkeypatch.setattr("src.search_filter_ui.messagebox.showwarning", lambda *a, **k: None) monkeypatch.setattr("src.search_filter_ui.messagebox.showwarning", lambda *_a, **_k: None)
w._load_preset() w._load_preset()
+1 -1
View File
@@ -255,7 +255,7 @@ class TestIntegrationSuite:
root.destroy() root.destroy()
@patch('tkinter.messagebox') @patch('tkinter.messagebox')
def test_data_validation_and_error_handling(self, mock_messagebox): def test_data_validation_and_error_handling(self, _mock_messagebox):
"""Test data validation and error handling throughout the system.""" """Test data validation and error handling throughout the system."""
print("Testing data validation and error handling...") print("Testing data validation and error handling...")
+1 -1
View File
@@ -282,7 +282,7 @@ class TestUIManager:
assert medicine_data[0].get() == 0 # IntVar should be 0 assert medicine_data[0].get() == 0 # IntVar should be 0
@patch('tkinter.messagebox.showerror') @patch('tkinter.messagebox.showerror')
def test_error_handling_in_setup_application_icon(self, mock_showerror, ui_manager): def test_error_handling_in_setup_application_icon(self, _mock_showerror, ui_manager):
"""Test error handling in setup_application_icon method.""" """Test error handling in setup_application_icon method."""
with patch('PIL.Image.open') as mock_open: with patch('PIL.Image.open') as mock_open:
mock_open.side_effect = Exception("Image error") mock_open.side_effect = Exception("Image error")