@@ -32,7 +32,7 @@ def test_use_ttk(self):
3232 d = self .create (buttons = ['OK' ], bitmap = 'warning' )
3333 self .assertEqual (d ._buttons [0 ].winfo_class (), 'TButton' )
3434 self .assertEqual (d .message .winfo_class (), 'TLabel' )
35- self .assertEqual (str ( d .message .cget ('anchor' ) ), 'nw' ) # cf. MessageBox
35+ self .assertEqual (d .message .cget ('anchor' ), 'nw' ) # cf. MessageBox
3636 # The standard icons are drawn with themed images (cf. MessageBox).
3737 self .assertEqual (d .bitmap .winfo_class (), 'TLabel' )
3838 self .assertIn ('::tk::icons::warning' , str (d .bitmap .cget ('image' )))
@@ -57,7 +57,7 @@ def test_use_classic(self):
5757 self .assertEqual (d ._buttons [0 ].winfo_class (), 'Button' )
5858 self .assertEqual (d .message .winfo_class (), 'Label' )
5959 if d .root ._windowingsystem == 'x11' :
60- self .assertEqual (str ( d .frame .cget ('relief' ) ), 'raised' )
60+ self .assertEqual (d .frame .cget ('relief' ), 'raised' )
6161 # tk_dialog does not make the buttons equal width.
6262 self .assertIsNone (d .root .children ['bot' ].grid_columnconfigure (0 )['uniform' ])
6363 # The bitmap is a classic monochrome label.
@@ -75,17 +75,20 @@ def test_no_detail(self):
7575 # Without a detail message the message label expands.
7676 d = self .create ()
7777 self .assertIsNone (d .detail )
78- self .assertEqual (int (d .message .pack_info ()['expand' ]), 1 )
78+ self .assertEqual (d .message .pack_info ()['expand' ],
79+ 1 if self .wantobjects else '1' )
7980
8081 def test_detail (self ):
8182 # The detail message is shown below the main message.
8283 d = self .create (detail = 'More information.' )
8384 self .assertEqual (d .detail .winfo_class (), 'TLabel' )
8485 self .assertEqual (str (d .detail .cget ('text' )), 'More information.' )
85- self .assertEqual (str ( d .detail .cget ('anchor' ) ), 'nw' ) # cf. MessageBox
86+ self .assertEqual (d .detail .cget ('anchor' ), 'nw' ) # cf. MessageBox
8687 # With a detail message it expands and the main message does not.
87- self .assertEqual (int (d .message .pack_info ()['expand' ]), 0 )
88- self .assertEqual (int (d .detail .pack_info ()['expand' ]), 1 )
88+ self .assertEqual (d .message .pack_info ()['expand' ],
89+ 0 if self .wantobjects else '0' )
90+ self .assertEqual (d .detail .pack_info ()['expand' ],
91+ 1 if self .wantobjects else '1' )
8992
9093 def test_bitmap_fallback (self ):
9194 # A non-standard bitmap has no themed image, so even the ttk version
@@ -114,11 +117,11 @@ def test_button_options(self):
114117 yes , no = d ._buttons
115118 self .assertEqual (str (yes .cget ('text' )), 'Yes' )
116119 self .assertEqual (str (no .cget ('text' )), 'No' )
117- self .assertEqual (int ( no .cget ('underline' )) , 0 )
120+ self .assertEqual (no .cget ('underline' ), 0 if self . wantobjects else '0' )
118121 self .assertEqual (str (no .cget ('width' )), '12' )
119122 # The dialog still controls the default ring (default=0) ...
120- self .assertEqual (str ( yes .cget ('default' ) ), 'active' )
121- self .assertEqual (str ( no .cget ('default' ) ), 'normal' )
123+ self .assertEqual (yes .cget ('default' ), 'active' )
124+ self .assertEqual (no .cget ('default' ), 'normal' )
122125 # ... and the command, which records the button index.
123126 no .invoke ()
124127 self .assertEqual (d .num , 1 )
@@ -128,13 +131,13 @@ def test_default_ring(self):
128131 # (cf. tk::MessageBox).
129132 d = self .create () # buttons ['Yes', 'No'], default 0
130133 b0 , b1 = d ._buttons
131- self .assertEqual (str ( b1 .cget ('default' ) ), 'normal' )
134+ self .assertEqual (b1 .cget ('default' ), 'normal' )
132135 b1 .focus_force ()
133136 d .root .update ()
134- self .assertEqual (str ( b1 .cget ('default' ) ), 'active' ) # focused -> ring
137+ self .assertEqual (b1 .cget ('default' ), 'active' ) # focused -> ring
135138 b0 .focus_force ()
136139 d .root .update ()
137- self .assertEqual (str ( b1 .cget ('default' ) ), 'normal' ) # unfocused -> none
140+ self .assertEqual (b1 .cget ('default' ), 'normal' ) # unfocused -> none
138141
139142 def test_alt_key (self ):
140143 # Alt + an underlined character (the "underline" button option) invokes
@@ -269,7 +272,7 @@ def test_use_classic(self):
269272 self .assertEqual (d .children ['ok' ].winfo_class (), 'Button' )
270273 self .assertEqual (d .entry .winfo_class (), 'Entry' )
271274 if d ._windowingsystem == 'x11' :
272- self .assertEqual (str ( d .children ['bot' ].cget ('relief' ) ), 'raised' )
275+ self .assertEqual (d .children ['bot' ].cget ('relief' ), 'raised' )
273276 # tk_dialog does not make the buttons equal width.
274277 self .assertIsNone (d .children ['bot' ].grid_columnconfigure (0 )['uniform' ])
275278 # The bindings work with the classic buttons too.
@@ -311,8 +314,8 @@ def body(self, master):
311314
312315 def test_button_default (self ):
313316 d = self .open ()
314- self .assertEqual (str ( d .children ['ok' ].cget ('default' ) ), 'active' )
315- self .assertEqual (str ( d .children ['cancel' ].cget ('default' ) ), 'normal' )
317+ self .assertEqual (d .children ['ok' ].cget ('default' ), 'active' )
318+ self .assertEqual (d .children ['cancel' ].cget ('default' ), 'normal' )
316319
317320 def test_underline_ampersand (self ):
318321 self .assertEqual (_underline_ampersand ('Yes' ), ('Yes' , - 1 ))
@@ -326,19 +329,19 @@ def test_button_accelerator(self):
326329 d = self .open ()
327330 ok = d .children ['ok' ] # "&OK" -> underline 0 -> "O"
328331 self .assertEqual (str (ok .cget ('text' )), 'OK' )
329- self .assertEqual (int ( ok .cget ('underline' )) , 0 )
332+ self .assertEqual (ok .cget ('underline' ), 0 if self . wantobjects else '0' )
330333
331334 def test_default_ring (self ):
332335 # The default ring follows the keyboard focus among the buttons.
333336 d = self .open ()
334337 cancel = d .children ['cancel' ]
335- self .assertEqual (str ( cancel .cget ('default' ) ), 'normal' )
338+ self .assertEqual (cancel .cget ('default' ), 'normal' )
336339 cancel .focus_force ()
337340 d .update ()
338- self .assertEqual (str ( cancel .cget ('default' ) ), 'active' )
341+ self .assertEqual (cancel .cget ('default' ), 'active' )
339342 d .children ['ok' ].focus_force ()
340343 d .update ()
341- self .assertEqual (str ( cancel .cget ('default' ) ), 'normal' )
344+ self .assertEqual (cancel .cget ('default' ), 'normal' )
342345
343346 def test_find_alt_key_target (self ):
344347 d = self .open ()
0 commit comments