Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b3de1a7

Browse files
Issue #19761: Fixed Tkinter tests on OS X.
1 parent 1317e14 commit b3de1a7

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

Lib/tkinter/test/test_tkinter/test_widgets.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,11 @@ def test_disabledbackground(self):
329329
self.checkColorParam(widget, 'disabledbackground')
330330

331331
def test_insertborderwidth(self):
332-
widget = self.create()
333-
self.checkPixelsParam(widget, 'insertborderwidth', 0, 1.3, -2)
334-
self.checkParam(widget, 'insertborderwidth', 2, expected=1)
335-
self.checkParam(widget, 'insertborderwidth', '10p', expected=1)
332+
widget = self.create(insertwidth=100)
333+
self.checkPixelsParam(widget, 'insertborderwidth',
334+
0, 1.3, 2.6, 6, -2, '10p')
335+
# insertborderwidth is bounded above by a half of insertwidth.
336+
self.checkParam(widget, 'insertborderwidth', 60, expected=100//2)
336337

337338
def test_insertwidth(self):
338339
widget = self.create()

Lib/tkinter/test/widget_tests.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from tkinter.ttk import setup_master, Scale
77
from tkinter.test.support import (tcl_version, requires_tcl, get_tk_patchlevel,
88
pixels_conv, tcl_obj_eq)
9+
import test.support
910

1011

1112
noconv = False
@@ -234,8 +235,14 @@ def test_bitmap(self):
234235
widget = self.create()
235236
self.checkParam(widget, 'bitmap', 'questhead')
236237
self.checkParam(widget, 'bitmap', 'gray50')
237-
self.checkInvalidParam(widget, 'bitmap', 'spam',
238-
errmsg='bitmap "spam" not defined')
238+
filename = test.support.findfile('python.xbm', subdir='imghdrdata')
239+
self.checkParam(widget, 'bitmap', '@' + filename)
240+
# Cocoa Tk widgets don't detect invalid -bitmap values
241+
# See https://core.tcl.tk/tk/info/31cd33dbf0
242+
if not ('aqua' in self.root.tk.call('tk', 'windowingsystem') and
243+
'AppKit' in self.root.winfo_server()):
244+
self.checkInvalidParam(widget, 'bitmap', 'spam',
245+
errmsg='bitmap "spam" not defined')
239246

240247
def test_borderwidth(self):
241248
widget = self.create()
@@ -495,7 +502,6 @@ def test(self, option=option):
495502
return decorator
496503

497504
def setUpModule():
498-
import test.support
499505
if test.support.verbose:
500506
tcl = tkinter.Tcl()
501507
print('patchlevel =', tcl.call('info', 'patchlevel'))

0 commit comments

Comments
 (0)