From 87b59cd64a9368508ad2c5f5985ca4f70c79d23f Mon Sep 17 00:00:00 2001 From: William Valentin Date: Fri, 8 Aug 2025 17:44:50 -0700 Subject: [PATCH] refactor: Update exception handling parameters in context managers for consistency --- src/error_handler.py | 2 +- tests/test_dose_parsing.py | 12 +++++++++--- tests/test_export_manager.py | 2 +- tests/test_filter_presets.py | 2 +- tests/test_integration.py | 2 +- tests/test_ui_manager.py | 2 +- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/error_handler.py b/src/error_handler.py index 86f3daf..8275e7b 100644 --- a/src/error_handler.py +++ b/src/error_handler.py @@ -245,7 +245,7 @@ class OperationTimer: self.start_time = time.time() 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.""" import time diff --git a/tests/test_dose_parsing.py b/tests/test_dose_parsing.py index 5efaba7..45cdc70 100644 --- a/tests/test_dose_parsing.py +++ b/tests/test_dose_parsing.py @@ -11,9 +11,15 @@ def root_window(): @pytest.fixture def ui_manager(root_window): class DummyLogger: - def debug(self, *a, **k): pass - def warning(self, *a, **k): pass - def error(self, *a, **k): pass + def debug(self, *_args, **_kwargs): + pass + + def warning(self, *_args, **_kwargs): + pass + + def error(self, *_args, **_kwargs): + pass + return UIManager(root_window, DummyLogger()) def test_parse_dose_history_for_saving_bullet_and_delete(ui_manager): diff --git a/tests/test_export_manager.py b/tests/test_export_manager.py index a02e95d..9af8018 100644 --- a/tests/test_export_manager.py +++ b/tests/test_export_manager.py @@ -152,7 +152,7 @@ class TestExportManager: @patch('matplotlib.pyplot.draw') @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.""" with tempfile.TemporaryDirectory() as temp_dir: temp_path = Path(temp_dir) diff --git a/tests/test_filter_presets.py b/tests/test_filter_presets.py index 76e0bf4..b5dbdc0 100644 --- a/tests/test_filter_presets.py +++ b/tests/test_filter_presets.py @@ -98,7 +98,7 @@ def test_load_preset_applies_filters(widget, monkeypatch): w.preset_var.set("MyPreset") # 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() diff --git a/tests/test_integration.py b/tests/test_integration.py index 58d67cb..ff53156 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -255,7 +255,7 @@ class TestIntegrationSuite: root.destroy() @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.""" print("Testing data validation and error handling...") diff --git a/tests/test_ui_manager.py b/tests/test_ui_manager.py index 5ff895c..06ccd26 100644 --- a/tests/test_ui_manager.py +++ b/tests/test_ui_manager.py @@ -282,7 +282,7 @@ class TestUIManager: assert medicine_data[0].get() == 0 # IntVar should be 0 @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.""" with patch('PIL.Image.open') as mock_open: mock_open.side_effect = Exception("Image error")