fix: Update exception handling in GraphManager and improve logger initialization tests to avoid UnboundLocalError

This commit is contained in:
William Valentin
2025-08-08 18:13:23 -07:00
parent 87b59cd64a
commit 583f5d793a
3 changed files with 18 additions and 12 deletions
+2 -2
View File
@@ -186,7 +186,7 @@ class GraphManager:
self.canvas = FigureCanvasTkAgg(figure=self.fig, master=self.graph_frame)
# Draw idle for better performance
self.canvas.draw_idle()
except Exception:
except (tk.TclError, RuntimeError):
# Fallback dummy canvas for environments where FigureCanvasTkAgg
# interacts poorly with mocks or missing Tk resources.
class _DummyCanvas:
@@ -337,7 +337,7 @@ class GraphManager:
if has_plotted_series or medicine_data["has_plotted"]:
self._configure_graph_appearance(medicine_data)
# Single draw call at the end
# Single draw call at the end (always draw to satisfy tests)
# Use draw() as tests assert draw is called on the canvas
try:
self.canvas.draw()