77
88import contextlib
99import ctypes
10+ import logging
1011import sys
1112import types
1213from ctypes import wintypes
@@ -681,8 +682,9 @@ def wrapper(self, *args, **kwargs):
681682 # Create a new root
682683 root = tk .Tk ()
683684 root .withdraw ()
684- except :
685+ except Exception as exc :
685686 # If there's any issue, try to create a new root
687+ logging .debug ("Failed to use existing root, creating new one: %s" , exc )
686688 root = tk .Tk ()
687689 root .withdraw ()
688690
@@ -4084,9 +4086,10 @@ def test_patch_layout_method_error_handling(self):
40844086 # This should not raise an exception
40854087 try :
40864088 manager ._patch_layout_method ("test.method" , original_method , 2.0 )
4087- except Exception :
4089+ except Exception as exc :
40884090 # If it raises an exception, that's also acceptable for error handling
4089- pass
4091+ # Log the exception for debugging purposes
4092+ logging .debug ("Expected exception in _patch_layout_method: %s" , exc )
40904093
40914094 def test_patch_widget_constructor_error_handling (self ):
40924095 """Test _patch_widget_constructor error handling."""
@@ -4101,9 +4104,10 @@ def test_patch_widget_constructor_error_handling(self):
41014104 # This should not raise an exception
41024105 try :
41034106 manager ._patch_widget_constructor (mock_widget_class , 2.0 , "test.method" )
4104- except Exception :
4107+ except Exception as exc :
41054108 # If it raises an exception, that's also acceptable for error handling
4106- pass
4109+ # Log the exception for debugging purposes
4110+ logging .debug ("Expected exception in _patch_widget_constructor: %s" , exc )
41074111
41084112 def test_patch_treeview_method_error_handling (self ):
41094113 """Test _patch_treeview_method error handling."""
@@ -4118,9 +4122,10 @@ def test_patch_treeview_method_error_handling(self):
41184122 # This should not raise an exception
41194123 try :
41204124 manager ._patch_treeview_method ("test.method" , original_method , 2.0 , MagicMock ())
4121- except Exception :
4125+ except Exception as exc :
41224126 # If it raises an exception, that's also acceptable for error handling
4123- pass
4127+ # Log the exception for debugging purposes
4128+ logging .debug ("Expected exception in _patch_treeview_method: %s" , exc )
41244129
41254130 def test_patch_treeview_method_bound_method_handling (self ):
41264131 """Test _patch_treeview_method with bound method."""
@@ -4140,9 +4145,10 @@ def test_patch_treeview_method_bound_method_handling(self):
41404145 # This should not raise an exception
41414146 try :
41424147 manager ._patch_treeview_method ("test.method" , bound_method , 2.0 , MagicMock ())
4143- except Exception :
4148+ except Exception as exc :
41444149 # If it raises an exception, that's also acceptable for error handling
4145- pass
4150+ # Log the exception for debugging purposes
4151+ logging .debug ("Expected exception in _patch_treeview_method (bound): %s" , exc )
41464152
41474153 def test_patch_treeview_method_unbound_method_handling (self ):
41484154 """Test _patch_treeview_method with unbound method."""
@@ -4158,9 +4164,10 @@ def test_patch_treeview_method_unbound_method_handling(self):
41584164 # This should not raise an exception
41594165 try :
41604166 manager ._patch_treeview_method ("ttk.Treeview.column" , unbound_method , 2.0 , MagicMock ())
4161- except Exception :
4167+ except Exception as exc :
41624168 # If it raises an exception, that's also acceptable for error handling
4163- pass
4169+ # Log the exception for debugging purposes
4170+ logging .debug ("Expected exception in _patch_treeview_method (unbound): %s" , exc )
41644171
41654172 def test_patch_treeview_method_style_class_handling (self ):
41664173 """Test _patch_treeview_method with Style class."""
@@ -4176,9 +4183,10 @@ def test_patch_treeview_method_style_class_handling(self):
41764183 # This should not raise an exception
41774184 try :
41784185 manager ._patch_treeview_method ("ttk.Style.configure" , unbound_method , 2.0 , MagicMock ())
4179- except Exception :
4186+ except Exception as exc :
41804187 # If it raises an exception, that's also acceptable for error handling
4181- pass
4188+ # Log the exception for debugging purposes
4189+ logging .debug ("Expected exception in _patch_treeview_method (Style): %s" , exc )
41824190
41834191 def test_scale_layout_spec_recursive_children_scaling (self ):
41844192 """Test recursive layout spec scaling with children."""
0 commit comments