Commit 95cf9862 authored by Serhiy Storchaka's avatar Serhiy Storchaka

Import Tkinter as tkinter to help merging and avoid backporting errors.

parent c208fe67
import unittest
import Tkinter
import Tkinter as tkinter
#from Tkinter
import tkFont as font
from test.test_support import requires, run_unittest
......@@ -19,7 +19,7 @@ class FontTest(unittest.TestCase):
fontname = "TkDefaultFont"
try:
f = font.Font(name=fontname, exists=True)
except Tkinter._tkinter.TclError:
except tkinter._tkinter.TclError:
f = font.Font(name=fontname, exists=False)
font1 = font.nametofont(fontname)
font2 = font.nametofont(fontname)
......
import unittest
import re
import Tkinter
import Tkinter as tkinter
from Tkinter import TclError
from test.test_support import requires, run_unittest
......@@ -13,13 +13,13 @@ requires('gui')
class PackTest(AbstractWidgetTest, unittest.TestCase):
def create2(self):
pack = Tkinter.Toplevel(self.root, name='pack')
pack = tkinter.Toplevel(self.root, name='pack')
pack.wm_geometry('300x200+0+0')
pack.wm_minsize(1, 1)
a = Tkinter.Frame(pack, name='a', width=20, height=40, bg='red')
b = Tkinter.Frame(pack, name='b', width=50, height=30, bg='blue')
c = Tkinter.Frame(pack, name='c', width=80, height=80, bg='green')
d = Tkinter.Frame(pack, name='d', width=40, height=30, bg='yellow')
a = tkinter.Frame(pack, name='a', width=20, height=40, bg='red')
b = tkinter.Frame(pack, name='b', width=50, height=30, bg='blue')
c = tkinter.Frame(pack, name='c', width=80, height=80, bg='green')
d = tkinter.Frame(pack, name='d', width=40, height=30, bg='yellow')
return pack, a, b, c, d
def test_pack_configure_after(self):
......@@ -277,11 +277,11 @@ class PackTest(AbstractWidgetTest, unittest.TestCase):
class PlaceTest(AbstractWidgetTest, unittest.TestCase):
def create2(self):
t = Tkinter.Toplevel(self.root, width=300, height=200, bd=0)
t = tkinter.Toplevel(self.root, width=300, height=200, bd=0)
t.wm_geometry('+0+0')
f = Tkinter.Frame(t, width=154, height=84, bd=2, relief='raised')
f = tkinter.Frame(t, width=154, height=84, bd=2, relief='raised')
f.place_configure(x=48, y=38)
f2 = Tkinter.Frame(t, width=30, height=60, bd=2, relief='raised')
f2 = tkinter.Frame(t, width=30, height=60, bd=2, relief='raised')
self.root.update()
return t, f, f2
......@@ -369,7 +369,7 @@ class PlaceTest(AbstractWidgetTest, unittest.TestCase):
f2.place_configure(in_=f, rely='spam')
def test_place_configure_anchor(self):
f = Tkinter.Frame(self.root)
f = tkinter.Frame(self.root)
with self.assertRaisesRegexp(TclError, 'bad anchor "j"'):
f.place_configure(anchor='j')
with self.assertRaisesRegexp(TclError, 'ambiguous anchor ""'):
......@@ -425,7 +425,7 @@ class PlaceTest(AbstractWidgetTest, unittest.TestCase):
f2.place_configure(relheight='abcd')
def test_place_configure_bordermode(self):
f = Tkinter.Frame(self.root)
f = tkinter.Frame(self.root)
with self.assertRaisesRegexp(TclError, 'bad bordermode "j"'):
f.place_configure(bordermode='j')
with self.assertRaisesRegexp(TclError, 'ambiguous bordermode ""'):
......@@ -435,7 +435,7 @@ class PlaceTest(AbstractWidgetTest, unittest.TestCase):
self.assertEqual(f.place_info()['bordermode'], value)
def test_place_forget(self):
foo = Tkinter.Frame(self.root)
foo = tkinter.Frame(self.root)
foo.place_configure(width=50, height=50)
self.root.update()
foo.place_forget()
......@@ -467,8 +467,8 @@ class PlaceTest(AbstractWidgetTest, unittest.TestCase):
f2.place_info(0)
def test_place_slaves(self):
foo = Tkinter.Frame(self.root)
bar = Tkinter.Frame(self.root)
foo = tkinter.Frame(self.root)
bar = tkinter.Frame(self.root)
self.assertEqual(foo.place_slaves(), [])
bar.place_configure(in_=foo)
self.assertEqual(foo.place_slaves(), [bar])
......@@ -488,7 +488,7 @@ class GridTest(AbstractWidgetTest, unittest.TestCase):
self.root.grid_propagate(1)
def test_grid_configure(self):
b = Tkinter.Button(self.root)
b = tkinter.Button(self.root)
self.addCleanup(b.destroy)
self.assertEqual(b.grid_info(), {})
b.grid_configure()
......@@ -500,7 +500,7 @@ class GridTest(AbstractWidgetTest, unittest.TestCase):
self.assertEqual(b.grid_info()['row'], self._str(2))
def test_grid_configure_column(self):
b = Tkinter.Button(self.root)
b = tkinter.Button(self.root)
with self.assertRaisesRegexp(TclError, 'bad column value "-1": '
'must be a non-negative integer'):
b.grid_configure(column=-1)
......@@ -508,7 +508,7 @@ class GridTest(AbstractWidgetTest, unittest.TestCase):
self.assertEqual(b.grid_info()['column'], self._str(2))
def test_grid_configure_columnspan(self):
b = Tkinter.Button(self.root)
b = tkinter.Button(self.root)
with self.assertRaisesRegexp(TclError, 'bad columnspan value "0": '
'must be a positive integer'):
b.grid_configure(columnspan=0)
......@@ -516,8 +516,8 @@ class GridTest(AbstractWidgetTest, unittest.TestCase):
self.assertEqual(b.grid_info()['columnspan'], self._str(2))
def test_grid_configure_in(self):
f = Tkinter.Frame(self.root)
b = Tkinter.Button(self.root)
f = tkinter.Frame(self.root)
b = tkinter.Button(self.root)
self.assertEqual(b.grid_info(), {})
b.grid_configure()
self.assertEqual(b.grid_info()['in'], self.root)
......@@ -527,7 +527,7 @@ class GridTest(AbstractWidgetTest, unittest.TestCase):
self.assertEqual(b.grid_info()['in'], self.root)
def test_grid_configure_ipadx(self):
b = Tkinter.Button(self.root)
b = tkinter.Button(self.root)
with self.assertRaisesRegexp(TclError, 'bad ipadx value "-1": '
'must be positive screen distance'):
b.grid_configure(ipadx=-1)
......@@ -538,7 +538,7 @@ class GridTest(AbstractWidgetTest, unittest.TestCase):
self._str(int_round(pixels_conv('.5c') * self.scaling)))
def test_grid_configure_ipady(self):
b = Tkinter.Button(self.root)
b = tkinter.Button(self.root)
with self.assertRaisesRegexp(TclError, 'bad ipady value "-1": '
'must be positive screen distance'):
b.grid_configure(ipady=-1)
......@@ -549,7 +549,7 @@ class GridTest(AbstractWidgetTest, unittest.TestCase):
self._str(int_round(pixels_conv('.5c') * self.scaling)))
def test_grid_configure_padx(self):
b = Tkinter.Button(self.root)
b = tkinter.Button(self.root)
with self.assertRaisesRegexp(TclError, 'bad pad value "-1": '
'must be positive screen distance'):
b.grid_configure(padx=-1)
......@@ -562,7 +562,7 @@ class GridTest(AbstractWidgetTest, unittest.TestCase):
self._str(int_round(pixels_conv('.5c') * self.scaling)))
def test_grid_configure_pady(self):
b = Tkinter.Button(self.root)
b = tkinter.Button(self.root)
with self.assertRaisesRegexp(TclError, 'bad pad value "-1": '
'must be positive screen distance'):
b.grid_configure(pady=-1)
......@@ -575,7 +575,7 @@ class GridTest(AbstractWidgetTest, unittest.TestCase):
self._str(int_round(pixels_conv('.5c') * self.scaling)))
def test_grid_configure_row(self):
b = Tkinter.Button(self.root)
b = tkinter.Button(self.root)
self.addCleanup(b.destroy)
with self.assertRaisesRegexp(TclError, 'bad (row|grid) value "-1": '
'must be a non-negative integer'):
......@@ -584,7 +584,7 @@ class GridTest(AbstractWidgetTest, unittest.TestCase):
self.assertEqual(b.grid_info()['row'], self._str(2))
def test_grid_configure_rownspan(self):
b = Tkinter.Button(self.root)
b = tkinter.Button(self.root)
with self.assertRaisesRegexp(TclError, 'bad rowspan value "0": '
'must be a positive integer'):
b.grid_configure(rowspan=0)
......@@ -592,7 +592,7 @@ class GridTest(AbstractWidgetTest, unittest.TestCase):
self.assertEqual(b.grid_info()['rowspan'], self._str(2))
def test_grid_configure_sticky(self):
f = Tkinter.Frame(self.root, bg='red')
f = tkinter.Frame(self.root, bg='red')
with self.assertRaisesRegexp(TclError, 'bad stickyness value "glue"'):
f.grid_configure(sticky='glue')
f.grid_configure(sticky='ne')
......@@ -611,7 +611,7 @@ class GridTest(AbstractWidgetTest, unittest.TestCase):
with self.assertRaisesRegexp(TclError,
'must specify a single element on retrieval'):
self.root.grid_columnconfigure((0, 3))
b = Tkinter.Button(self.root)
b = tkinter.Button(self.root)
b.grid_configure(column=0, row=0)
if tcl_version >= (8, 5):
self.root.grid_columnconfigure('all', weight=3)
......@@ -667,7 +667,7 @@ class GridTest(AbstractWidgetTest, unittest.TestCase):
with self.assertRaisesRegexp(TclError,
'must specify a single element on retrieval'):
self.root.grid_rowconfigure((0, 3))
b = Tkinter.Button(self.root)
b = tkinter.Button(self.root)
b.grid_configure(column=0, row=0)
if tcl_version >= (8, 5):
self.root.grid_rowconfigure('all', weight=3)
......@@ -713,8 +713,8 @@ class GridTest(AbstractWidgetTest, unittest.TestCase):
self.assertEqual(self.root.grid_rowconfigure(0)['uniform'], 'foo')
def test_grid_forget(self):
b = Tkinter.Button(self.root)
c = Tkinter.Button(self.root)
b = tkinter.Button(self.root)
c = tkinter.Button(self.root)
b.grid_configure(row=2, column=2, rowspan=2, columnspan=2,
padx=3, pady=4, sticky='ns')
self.assertEqual(self.root.grid_slaves(), [b])
......@@ -733,8 +733,8 @@ class GridTest(AbstractWidgetTest, unittest.TestCase):
self.assertEqual(info['sticky'], '')
def test_grid_remove(self):
b = Tkinter.Button(self.root)
c = Tkinter.Button(self.root)
b = tkinter.Button(self.root)
c = tkinter.Button(self.root)
b.grid_configure(row=2, column=2, rowspan=2, columnspan=2,
padx=3, pady=4, sticky='ns')
self.assertEqual(self.root.grid_slaves(), [b])
......@@ -753,7 +753,7 @@ class GridTest(AbstractWidgetTest, unittest.TestCase):
self.assertEqual(info['sticky'], 'ns')
def test_grid_info(self):
b = Tkinter.Button(self.root)
b = tkinter.Button(self.root)
self.assertEqual(b.grid_info(), {})
b.grid_configure(row=2, column=2, rowspan=2, columnspan=2,
padx=3, pady=4, sticky='ns')
......@@ -782,12 +782,12 @@ class GridTest(AbstractWidgetTest, unittest.TestCase):
self.root.grid_bbox(0, 0, 0, 'x')
with self.assertRaises(TypeError):
self.root.grid_bbox(0, 0, 0, 0, 0)
t = Tkinter.Toplevel(self.root)
t = tkinter.Toplevel(self.root)
# de-maximize
t.wm_geometry('1x1+0+0')
t.wm_geometry('')
f1 = Tkinter.Frame(t, width=75, height=75, bg='red')
f2 = Tkinter.Frame(t, width=90, height=90, bg='blue')
f1 = tkinter.Frame(t, width=75, height=75, bg='red')
f2 = tkinter.Frame(t, width=90, height=90, bg='blue')
f1.grid_configure(row=0, column=0)
f2.grid_configure(row=1, column=1)
self.root.update()
......@@ -810,11 +810,11 @@ class GridTest(AbstractWidgetTest, unittest.TestCase):
self.root.grid_location('x', 'y')
with self.assertRaisesRegexp(TclError, 'bad screen distance "y"'):
self.root.grid_location('1c', 'y')
t = Tkinter.Toplevel(self.root)
t = tkinter.Toplevel(self.root)
# de-maximize
t.wm_geometry('1x1+0+0')
t.wm_geometry('')
f = Tkinter.Frame(t, width=200, height=100,
f = tkinter.Frame(t, width=200, height=100,
highlightthickness=0, bg='red')
self.assertEqual(f.grid_location(10, 10), (-1, -1))
f.grid_configure()
......@@ -837,13 +837,13 @@ class GridTest(AbstractWidgetTest, unittest.TestCase):
self.root.grid_propagate(False, False)
self.root.grid_propagate(False)
self.assertFalse(self.root.grid_propagate())
f = Tkinter.Frame(self.root, width=100, height=100, bg='red')
f = tkinter.Frame(self.root, width=100, height=100, bg='red')
f.grid_configure(row=0, column=0)
self.root.update()
self.assertEqual(f.winfo_width(), 100)
self.assertEqual(f.winfo_height(), 100)
f.grid_propagate(False)
g = Tkinter.Frame(self.root, width=75, height=85, bg='green')
g = tkinter.Frame(self.root, width=75, height=85, bg='green')
g.grid_configure(in_=f, row=0, column=0)
self.root.update()
self.assertEqual(f.winfo_width(), 100)
......@@ -857,7 +857,7 @@ class GridTest(AbstractWidgetTest, unittest.TestCase):
with self.assertRaises(TypeError):
self.root.grid_size(0)
self.assertEqual(self.root.grid_size(), (0, 0))
f = Tkinter.Scale(self.root)
f = tkinter.Scale(self.root)
f.grid_configure(row=0, column=0)
self.assertEqual(self.root.grid_size(), (1, 1))
f.grid_configure(row=4, column=5)
......@@ -865,13 +865,13 @@ class GridTest(AbstractWidgetTest, unittest.TestCase):
def test_grid_slaves(self):
self.assertEqual(self.root.grid_slaves(), [])
a = Tkinter.Label(self.root)
a = tkinter.Label(self.root)
a.grid_configure(row=0, column=1)
b = Tkinter.Label(self.root)
b = tkinter.Label(self.root)
b.grid_configure(row=1, column=0)
c = Tkinter.Label(self.root)
c = tkinter.Label(self.root)
c.grid_configure(row=1, column=1)
d = Tkinter.Label(self.root)
d = tkinter.Label(self.root)
d.grid_configure(row=1, column=1)
self.assertEqual(self.root.grid_slaves(), [d, c, b, a])
self.assertEqual(self.root.grid_slaves(row=0), [a])
......
import unittest
import Tkinter
import Tkinter as tkinter
from test.test_support import requires, run_unittest
from ttk import setup_master
......@@ -9,7 +9,7 @@ class TextTest(unittest.TestCase):
def setUp(self):
self.root = setup_master()
self.text = Tkinter.Text(self.root)
self.text = tkinter.Text(self.root)
def tearDown(self):
self.text.destroy()
......@@ -30,12 +30,12 @@ class TextTest(unittest.TestCase):
text = self.text
# pattern and index are obligatory arguments.
self.assertRaises(Tkinter.TclError, text.search, None, '1.0')
self.assertRaises(Tkinter.TclError, text.search, 'a', None)
self.assertRaises(Tkinter.TclError, text.search, None, None)
self.assertRaises(tkinter.TclError, text.search, None, '1.0')
self.assertRaises(tkinter.TclError, text.search, 'a', None)
self.assertRaises(tkinter.TclError, text.search, None, None)
# Invalid text index.
self.assertRaises(Tkinter.TclError, text.search, '', 0)
self.assertRaises(tkinter.TclError, text.search, '', 0)
# Check if we are getting the indices as strings -- you are likely
# to get Tcl_Obj under Tk 8.5 if Tkinter doesn't convert it.
......
import unittest
import Tkinter
import Tkinter as tkinter
from Tkinter import TclError
import os
import sys
......@@ -64,11 +64,11 @@ class ToplevelTest(AbstractToplevelTest, unittest.TestCase):
)
def _create(self, **kwargs):
return Tkinter.Toplevel(self.root, **kwargs)
return tkinter.Toplevel(self.root, **kwargs)
def test_menu(self):
widget = self.create()
menu = Tkinter.Menu(self.root)
menu = tkinter.Menu(self.root)
self.checkParam(widget, 'menu', menu, eq=widget_eq)
self.checkParam(widget, 'menu', '')
......@@ -103,7 +103,7 @@ class FrameTest(AbstractToplevelTest, unittest.TestCase):
)
def _create(self, **kwargs):
return Tkinter.Frame(self.root, **kwargs)
return tkinter.Frame(self.root, **kwargs)
@add_standard_options(StandardOptionsTests)
......@@ -118,7 +118,7 @@ class LabelFrameTest(AbstractToplevelTest, unittest.TestCase):
)
def _create(self, **kwargs):
return Tkinter.LabelFrame(self.root, **kwargs)
return tkinter.LabelFrame(self.root, **kwargs)
def test_labelanchor(self):
widget = self.create()
......@@ -129,7 +129,7 @@ class LabelFrameTest(AbstractToplevelTest, unittest.TestCase):
def test_labelwidget(self):
widget = self.create()
label = Tkinter.Label(self.root, text='Mupp', name='foo')
label = tkinter.Label(self.root, text='Mupp', name='foo')
self.checkParam(widget, 'labelwidget', label, expected='.foo')
label.destroy()
......@@ -156,7 +156,7 @@ class LabelTest(AbstractLabelTest, unittest.TestCase):
)
def _create(self, **kwargs):
return Tkinter.Label(self.root, **kwargs)
return tkinter.Label(self.root, **kwargs)
@add_standard_options(StandardOptionsTests)
......@@ -173,7 +173,7 @@ class ButtonTest(AbstractLabelTest, unittest.TestCase):
'underline', 'width', 'wraplength')
def _create(self, **kwargs):
return Tkinter.Button(self.root, **kwargs)
return tkinter.Button(self.root, **kwargs)
def test_default(self):
widget = self.create()
......@@ -197,7 +197,7 @@ class CheckbuttonTest(AbstractLabelTest, unittest.TestCase):
)
def _create(self, **kwargs):
return Tkinter.Checkbutton(self.root, **kwargs)
return tkinter.Checkbutton(self.root, **kwargs)
def test_offvalue(self):
......@@ -225,7 +225,7 @@ class RadiobuttonTest(AbstractLabelTest, unittest.TestCase):
)
def _create(self, **kwargs):
return Tkinter.Radiobutton(self.root, **kwargs)
return tkinter.Radiobutton(self.root, **kwargs)
def test_value(self):
widget = self.create()
......@@ -248,7 +248,7 @@ class MenubuttonTest(AbstractLabelTest, unittest.TestCase):
_conv_pixels = staticmethod(pixels_round)
def _create(self, **kwargs):
return Tkinter.Menubutton(self.root, **kwargs)
return tkinter.Menubutton(self.root, **kwargs)
def test_direction(self):
widget = self.create()
......@@ -265,21 +265,21 @@ class MenubuttonTest(AbstractLabelTest, unittest.TestCase):
'crashes with Cocoa Tk (issue19733)')
def test_image(self):
widget = self.create()
image = Tkinter.PhotoImage('image1')
image = tkinter.PhotoImage('image1')
self.checkParam(widget, 'image', image, conv=str)
errmsg = 'image "spam" doesn\'t exist'
with self.assertRaises(Tkinter.TclError) as cm:
with self.assertRaises(tkinter.TclError) as cm:
widget['image'] = 'spam'
if errmsg is not None:
self.assertEqual(str(cm.exception), errmsg)
with self.assertRaises(Tkinter.TclError) as cm:
with self.assertRaises(tkinter.TclError) as cm:
widget.configure({'image': 'spam'})
if errmsg is not None:
self.assertEqual(str(cm.exception), errmsg)
def test_menu(self):
widget = self.create()
menu = Tkinter.Menu(widget, name='menu')
menu = tkinter.Menu(widget, name='menu')
self.checkParam(widget, 'menu', menu, eq=widget_eq)
menu.destroy()
......@@ -301,7 +301,7 @@ class MenubuttonTest(AbstractLabelTest, unittest.TestCase):
class OptionMenuTest(MenubuttonTest, unittest.TestCase):
def _create(self, default='b', values=('a', 'b', 'c'), **kwargs):
return Tkinter.OptionMenu(self.root, None, default, *values, **kwargs)
return tkinter.OptionMenu(self.root, None, default, *values, **kwargs)
@add_standard_options(IntegerSizeTests, StandardOptionsTests)
......@@ -320,7 +320,7 @@ class EntryTest(AbstractWidgetTest, unittest.TestCase):
)
def _create(self, **kwargs):
return Tkinter.Entry(self.root, **kwargs)
return tkinter.Entry(self.root, **kwargs)
def test_disabledbackground(self):
widget = self.create()
......@@ -394,7 +394,7 @@ class SpinboxTest(EntryTest, unittest.TestCase):
)
def _create(self, **kwargs):
return Tkinter.Spinbox(self.root, **kwargs)
return tkinter.Spinbox(self.root, **kwargs)
test_show = None
......@@ -465,8 +465,8 @@ class SpinboxTest(EntryTest, unittest.TestCase):
def test_bbox(self):
widget = self.create()
self.assertIsBoundingBox(widget.bbox(0))
self.assertRaises(Tkinter.TclError, widget.bbox, 'noindex')
self.assertRaises(Tkinter.TclError, widget.bbox, None)
self.assertRaises(tkinter.TclError, widget.bbox, 'noindex')
self.assertRaises(tkinter.TclError, widget.bbox, None)
self.assertRaises(TypeError, widget.bbox)
self.assertRaises(TypeError, widget.bbox, 0, 1)
......@@ -490,7 +490,7 @@ class TextTest(AbstractWidgetTest, unittest.TestCase):
wantobjects = False
def _create(self, **kwargs):
return Tkinter.Text(self.root, **kwargs)
return tkinter.Text(self.root, **kwargs)
def test_autoseparators(self):
widget = self.create()
......@@ -619,10 +619,10 @@ class TextTest(AbstractWidgetTest, unittest.TestCase):
widget = self.create()
self.assertIsBoundingBox(widget.bbox('1.1'))
self.assertIsNone(widget.bbox('end'))
self.assertRaises(Tkinter.TclError, widget.bbox, 'noindex')
self.assertRaises(Tkinter.TclError, widget.bbox, None)
self.assertRaises(Tkinter.TclError, widget.bbox)
self.assertRaises(Tkinter.TclError, widget.bbox, '1.1', 'end')
self.assertRaises(tkinter.TclError, widget.bbox, 'noindex')
self.assertRaises(tkinter.TclError, widget.bbox, None)
self.assertRaises(tkinter.TclError, widget.bbox)
self.assertRaises(tkinter.TclError, widget.bbox, '1.1', 'end')
@add_standard_options(PixelSizeTests, StandardOptionsTests)
......@@ -644,7 +644,7 @@ class CanvasTest(AbstractWidgetTest, unittest.TestCase):
wantobjects = False
def _create(self, **kwargs):
return Tkinter.Canvas(self.root, **kwargs)
return tkinter.Canvas(self.root, **kwargs)
def test_closeenough(self):
widget = self.create()
......@@ -697,7 +697,7 @@ class ListboxTest(AbstractWidgetTest, unittest.TestCase):
)
def _create(self, **kwargs):
return Tkinter.Listbox(self.root, **kwargs)
return tkinter.Listbox(self.root, **kwargs)
def test_activestyle(self):
widget = self.create()
......@@ -706,7 +706,7 @@ class ListboxTest(AbstractWidgetTest, unittest.TestCase):
def test_listvariable(self):
widget = self.create()
var = Tkinter.DoubleVar()
var = tkinter.DoubleVar()
self.checkVariableParam(widget, 'listvariable', var)
def test_selectmode(self):
......@@ -789,7 +789,7 @@ class ListboxTest(AbstractWidgetTest, unittest.TestCase):
def test_curselection(self):
lb = self.create()
lb.insert(0, *('el%d' % i for i in range(8)))
lb.selection_clear(0, Tkinter.END)
lb.selection_clear(0, tkinter.END)
lb.selection_set(2, 4)
lb.selection_set(6)
self.assertEqual(lb.curselection(), (2, 3, 4, 6))
......@@ -829,7 +829,7 @@ class ScaleTest(AbstractWidgetTest, unittest.TestCase):
default_orient = 'vertical'
def _create(self, **kwargs):
return Tkinter.Scale(self.root, **kwargs)
return tkinter.Scale(self.root, **kwargs)
def test_bigincrement(self):
widget = self.create()
......@@ -898,7 +898,7 @@ class ScrollbarTest(AbstractWidgetTest, unittest.TestCase):
default_orient = 'vertical'
def _create(self, **kwargs):
return Tkinter.Scrollbar(self.root, **kwargs)
return tkinter.Scrollbar(self.root, **kwargs)
def test_activerelief(self):
widget = self.create()
......@@ -944,7 +944,7 @@ class PanedWindowTest(AbstractWidgetTest, unittest.TestCase):
default_orient = 'horizontal'
def _create(self, **kwargs):
return Tkinter.PanedWindow(self.root, **kwargs)
return tkinter.PanedWindow(self.root, **kwargs)
def test_handlepad(self):
widget = self.create()
......@@ -992,8 +992,8 @@ class PanedWindowTest(AbstractWidgetTest, unittest.TestCase):
def create2(self):
p = self.create()
b = Tkinter.Button(p)
c = Tkinter.Button(p)
b = tkinter.Button(p)
c = tkinter.Button(p)
p.add(b)
p.add(c)
return p, b, c
......@@ -1102,7 +1102,7 @@ class MenuTest(AbstractWidgetTest, unittest.TestCase):
_conv_pixels = noconv_meth
def _create(self, **kwargs):
return Tkinter.Menu(self.root, **kwargs)
return tkinter.Menu(self.root, **kwargs)
def test_postcommand(self):
widget = self.create()
......@@ -1150,8 +1150,8 @@ class MenuTest(AbstractWidgetTest, unittest.TestCase):
def test_entryconfigure_variable(self):
m1 = self.create()
v1 = Tkinter.BooleanVar(self.root)
v2 = Tkinter.BooleanVar(self.root)
v1 = tkinter.BooleanVar(self.root)
v2 = tkinter.BooleanVar(self.root)
m1.add_checkbutton(variable=v1, onvalue=True, offvalue=False,
label='Nonsense')
self.assertEqual(str(m1.entrycget(1, 'variable')), str(v1))
......@@ -1171,7 +1171,7 @@ class MessageTest(AbstractWidgetTest, unittest.TestCase):
_conv_pad_pixels = noconv_meth
def _create(self, **kwargs):
return Tkinter.Message(self.root, **kwargs)
return tkinter.Message(self.root, **kwargs)
def test_aspect(self):
widget = self.create()
......
import unittest
import Tkinter
import Tkinter as tkinter
def get_tk_root():
try:
root = Tkinter._default_root
root = tkinter._default_root
except AttributeError:
# it is possible to disable default root in Tkinter, although
# I haven't seen people doing it (but apparently someone did it
......@@ -12,7 +12,7 @@ def get_tk_root():
if root is None:
# create a new master only if there isn't one already
root = Tkinter.Tk()
root = tkinter.Tk()
return root
......@@ -45,7 +45,7 @@ _tk_patchlevel = None
def get_tk_patchlevel():
global _tk_patchlevel
if _tk_patchlevel is None:
tcl = Tkinter.Tcl()
tcl = tkinter.Tcl()
patchlevel = []
for x in tcl.call('info', 'patchlevel').split('.'):
try:
......@@ -82,7 +82,7 @@ def tcl_obj_eq(actual, expected):
def widget_eq(actual, expected):
if actual == expected:
return True
if isinstance(actual, (str, Tkinter.Widget)):
if isinstance(expected, (str, Tkinter.Widget)):
if isinstance(actual, (str, tkinter.Widget)):
if isinstance(expected, (str, tkinter.Widget)):
return str(actual) == str(expected)
return False
import sys
import unittest
import Tkinter
import Tkinter as tkinter
import ttk
from test.test_support import requires, run_unittest
......@@ -22,10 +22,10 @@ class LabeledScaleTest(unittest.TestCase):
x = ttk.LabeledScale()
var = x._variable._name
x.destroy()
self.assertRaises(Tkinter.TclError, x.tk.globalgetvar, var)
self.assertRaises(tkinter.TclError, x.tk.globalgetvar, var)
# manually created variable
myvar = Tkinter.DoubleVar()
myvar = tkinter.DoubleVar()
name = myvar._name
x = ttk.LabeledScale(variable=myvar)
x.destroy()
......@@ -34,10 +34,10 @@ class LabeledScaleTest(unittest.TestCase):
else:
self.assertEqual(float(x.tk.globalgetvar(name)), myvar.get())
del myvar
self.assertRaises(Tkinter.TclError, x.tk.globalgetvar, name)
self.assertRaises(tkinter.TclError, x.tk.globalgetvar, name)
# checking that the tracing callback is properly removed
myvar = Tkinter.IntVar()
myvar = tkinter.IntVar()
# LabeledScale will start tracing myvar
x = ttk.LabeledScale(variable=myvar)
x.destroy()
......@@ -48,15 +48,15 @@ class LabeledScaleTest(unittest.TestCase):
# it tries calling instance attributes not yet defined.
ttk.LabeledScale(variable=myvar)
if hasattr(sys, 'last_type'):
self.assertNotEqual(sys.last_type, Tkinter.TclError)
self.assertNotEqual(sys.last_type, tkinter.TclError)
def test_initialization(self):
# master passing
x = ttk.LabeledScale()
self.assertEqual(x.master, Tkinter._default_root)
self.assertEqual(x.master, tkinter._default_root)
x.destroy()
master = Tkinter.Frame()
master = tkinter.Frame()
x = ttk.LabeledScale(master)
self.assertEqual(x.master, master)
x.destroy()
......@@ -77,7 +77,7 @@ class LabeledScaleTest(unittest.TestCase):
self.assertRaises(ValueError, x._variable.get)
x.destroy()
# variable should have its default value set to the from_ value
myvar = Tkinter.DoubleVar(value=20)
myvar = tkinter.DoubleVar(value=20)
x = ttk.LabeledScale(variable=myvar)
self.assertEqual(x.value, 0)
x.destroy()
......@@ -105,7 +105,7 @@ class LabeledScaleTest(unittest.TestCase):
x.destroy()
# extra, and invalid, kwargs
self.assertRaises(Tkinter.TclError, ttk.LabeledScale, a='b')
self.assertRaises(tkinter.TclError, ttk.LabeledScale, a='b')
def test_horizontal_range(self):
......@@ -194,7 +194,7 @@ class OptionMenuTest(unittest.TestCase):
def setUp(self):
support.root_deiconify()
self.textvar = Tkinter.StringVar()
self.textvar = tkinter.StringVar()
def tearDown(self):
del self.textvar
......@@ -202,18 +202,18 @@ class OptionMenuTest(unittest.TestCase):
def test_widget_destroy(self):
var = Tkinter.StringVar()
var = tkinter.StringVar()
optmenu = ttk.OptionMenu(None, var)
name = var._name
optmenu.update_idletasks()
optmenu.destroy()
self.assertEqual(optmenu.tk.globalgetvar(name), var.get())
del var
self.assertRaises(Tkinter.TclError, optmenu.tk.globalgetvar, name)
self.assertRaises(tkinter.TclError, optmenu.tk.globalgetvar, name)
def test_initialization(self):
self.assertRaises(Tkinter.TclError,
self.assertRaises(tkinter.TclError,
ttk.OptionMenu, None, self.textvar, invalid='thing')
optmenu = ttk.OptionMenu(None, self.textvar, 'b', 'a', 'b')
......@@ -259,7 +259,7 @@ class OptionMenuTest(unittest.TestCase):
self.assertEqual(optmenu._variable.get(), items[0])
# changing to an invalid index shouldn't change the variable
self.assertRaises(Tkinter.TclError, optmenu['menu'].invoke, -1)
self.assertRaises(tkinter.TclError, optmenu['menu'].invoke, -1)
self.assertEqual(optmenu._variable.get(), items[0])
optmenu.destroy()
......
import unittest
import Tkinter
import Tkinter as tkinter
import ttk
from test.test_support import requires, run_unittest
......@@ -44,7 +44,7 @@ class StyleTest(unittest.TestCase):
def test_layout(self):
style = self.style
self.assertRaises(Tkinter.TclError, style.layout, 'NotALayout')
self.assertRaises(tkinter.TclError, style.layout, 'NotALayout')
tv_style = style.layout('Treeview')
# "erase" Treeview layout
......@@ -61,12 +61,12 @@ class StyleTest(unittest.TestCase):
self.assertIsInstance(style.layout('TButton'), list)
# correct layout, but "option" doesn't exist as option
self.assertRaises(Tkinter.TclError, style.layout, 'Treeview',
self.assertRaises(tkinter.TclError, style.layout, 'Treeview',
[('name', {'option': 'inexistent'})])
def test_theme_use(self):
self.assertRaises(Tkinter.TclError, self.style.theme_use,
self.assertRaises(tkinter.TclError, self.style.theme_use,
'nonexistingname')
curr_theme = self.style.theme_use()
......
import unittest
import Tkinter
import Tkinter as tkinter
import ttk
from test.test_support import requires, run_unittest
import sys
......@@ -76,9 +76,9 @@ class WidgetTest(unittest.TestCase):
), "label")
self.assertEqual(self.widget.identify(-1, -1), "")
self.assertRaises(Tkinter.TclError, self.widget.identify, None, 5)
self.assertRaises(Tkinter.TclError, self.widget.identify, 5, None)
self.assertRaises(Tkinter.TclError, self.widget.identify, 5, '')
self.assertRaises(tkinter.TclError, self.widget.identify, None, 5)
self.assertRaises(tkinter.TclError, self.widget.identify, 5, None)
self.assertRaises(tkinter.TclError, self.widget.identify, 5, '')
def test_widget_state(self):
......@@ -105,9 +105,9 @@ class WidgetTest(unittest.TestCase):
# attempt to set invalid statespec
currstate = self.widget.state()
self.assertRaises(Tkinter.TclError, self.widget.instate,
self.assertRaises(tkinter.TclError, self.widget.instate,
['badstate'])
self.assertRaises(Tkinter.TclError, self.widget.instate,
self.assertRaises(tkinter.TclError, self.widget.instate,
['disabled', 'badstate'])
# verify that widget didn't change its state
self.assertEqual(currstate, self.widget.state())
......@@ -162,8 +162,8 @@ class LabelFrameTest(AbstractToplevelTest, unittest.TestCase):
class AbstractLabelTest(AbstractWidgetTest):
def checkImageParam(self, widget, name):
image = Tkinter.PhotoImage('image1')
image2 = Tkinter.PhotoImage('image2')
image = tkinter.PhotoImage('image1')
image2 = tkinter.PhotoImage('image2')
self.checkParam(widget, name, image, expected=('image1',))
self.checkParam(widget, name, 'image1', expected=('image1',))
self.checkParam(widget, name, (image,), expected=('image1',))
......@@ -263,7 +263,7 @@ class CheckbuttonTest(AbstractLabelTest, unittest.TestCase):
# the variable automatically created by ttk.Checkbutton is actually
# undefined till we invoke the Checkbutton
self.assertEqual(cbtn.state(), ('alternate', ))
self.assertRaises(Tkinter.TclError, cbtn.tk.globalgetvar,
self.assertRaises(tkinter.TclError, cbtn.tk.globalgetvar,
cbtn['variable'])
res = cbtn.invoke()
......@@ -400,10 +400,10 @@ class ComboboxTest(AbstractWidgetTest, unittest.TestCase):
r'a\\tb {"a"} \}\ \{')
# out of range
self.assertRaises(Tkinter.TclError, self.combo.current,
self.assertRaises(tkinter.TclError, self.combo.current,
len(self.combo['values']))
# it expects an integer (or something that can be converted to int)
self.assertRaises(Tkinter.TclError, self.combo.current, '')
self.assertRaises(tkinter.TclError, self.combo.current, '')
# testing creating combobox with empty string in values
combo2 = ttk.Combobox(values=[1, 2, ''])
......@@ -462,8 +462,8 @@ class EntryTest(AbstractWidgetTest, unittest.TestCase):
def test_bbox(self):
self.assertIsBoundingBox(self.entry.bbox(0))
self.assertRaises(Tkinter.TclError, self.entry.bbox, 'noindex')
self.assertRaises(Tkinter.TclError, self.entry.bbox, None)
self.assertRaises(tkinter.TclError, self.entry.bbox, 'noindex')
self.assertRaises(tkinter.TclError, self.entry.bbox, None)
def test_identify(self):
......@@ -474,9 +474,9 @@ class EntryTest(AbstractWidgetTest, unittest.TestCase):
self.assertEqual(self.entry.identify(5, 5), "textarea")
self.assertEqual(self.entry.identify(-1, -1), "")
self.assertRaises(Tkinter.TclError, self.entry.identify, None, 5)
self.assertRaises(Tkinter.TclError, self.entry.identify, 5, None)
self.assertRaises(Tkinter.TclError, self.entry.identify, 5, '')
self.assertRaises(tkinter.TclError, self.entry.identify, None, 5)
self.assertRaises(tkinter.TclError, self.entry.identify, 5, None)
self.assertRaises(tkinter.TclError, self.entry.identify, 5, '')
def test_validation_options(self):
......@@ -504,7 +504,7 @@ class EntryTest(AbstractWidgetTest, unittest.TestCase):
self.assertEqual(len(success), 1)
self.entry['validatecommand'] = True
self.assertRaises(Tkinter.TclError, self.entry.validate)
self.assertRaises(tkinter.TclError, self.entry.validate)
def test_validation(self):
......@@ -585,49 +585,49 @@ class PanedWindowTest(AbstractWidgetTest, unittest.TestCase):
# attempt to add a child that is not a direct child of the paned window
label = ttk.Label(self.paned)
child = ttk.Label(label)
self.assertRaises(Tkinter.TclError, self.paned.add, child)
self.assertRaises(tkinter.TclError, self.paned.add, child)
label.destroy()
child.destroy()
# another attempt
label = ttk.Label()
child = ttk.Label(label)
self.assertRaises(Tkinter.TclError, self.paned.add, child)
self.assertRaises(tkinter.TclError, self.paned.add, child)
child.destroy()
label.destroy()
good_child = ttk.Label()
self.paned.add(good_child)
# re-adding a child is not accepted
self.assertRaises(Tkinter.TclError, self.paned.add, good_child)
self.assertRaises(tkinter.TclError, self.paned.add, good_child)
other_child = ttk.Label(self.paned)
self.paned.add(other_child)
self.assertEqual(self.paned.pane(0), self.paned.pane(1))
self.assertRaises(Tkinter.TclError, self.paned.pane, 2)
self.assertRaises(tkinter.TclError, self.paned.pane, 2)
good_child.destroy()
other_child.destroy()
self.assertRaises(Tkinter.TclError, self.paned.pane, 0)
self.assertRaises(tkinter.TclError, self.paned.pane, 0)
def test_forget(self):
self.assertRaises(Tkinter.TclError, self.paned.forget, None)
self.assertRaises(Tkinter.TclError, self.paned.forget, 0)
self.assertRaises(tkinter.TclError, self.paned.forget, None)
self.assertRaises(tkinter.TclError, self.paned.forget, 0)
self.paned.add(ttk.Label())
self.paned.forget(0)
self.assertRaises(Tkinter.TclError, self.paned.forget, 0)
self.assertRaises(tkinter.TclError, self.paned.forget, 0)
def test_insert(self):
self.assertRaises(Tkinter.TclError, self.paned.insert, None, 0)
self.assertRaises(Tkinter.TclError, self.paned.insert, 0, None)
self.assertRaises(Tkinter.TclError, self.paned.insert, 0, 0)
self.assertRaises(tkinter.TclError, self.paned.insert, None, 0)
self.assertRaises(tkinter.TclError, self.paned.insert, 0, None)
self.assertRaises(tkinter.TclError, self.paned.insert, 0, 0)
child = ttk.Label()
child2 = ttk.Label()
child3 = ttk.Label()
self.assertRaises(Tkinter.TclError, self.paned.insert, 0, child)
self.assertRaises(tkinter.TclError, self.paned.insert, 0, child)
self.paned.insert('end', child2)
self.paned.insert(0, child)
......@@ -654,7 +654,7 @@ class PanedWindowTest(AbstractWidgetTest, unittest.TestCase):
def test_pane(self):
self.assertRaises(Tkinter.TclError, self.paned.pane, 0)
self.assertRaises(tkinter.TclError, self.paned.pane, 0)
child = ttk.Label()
self.paned.add(child)
......@@ -666,21 +666,21 @@ class PanedWindowTest(AbstractWidgetTest, unittest.TestCase):
0 if self.wantobjects else '0')
self.assertEqual(self.paned.pane(0), self.paned.pane(str(child)))
self.assertRaises(Tkinter.TclError, self.paned.pane, 0,
self.assertRaises(tkinter.TclError, self.paned.pane, 0,
badoption='somevalue')
def test_sashpos(self):
self.assertRaises(Tkinter.TclError, self.paned.sashpos, None)
self.assertRaises(Tkinter.TclError, self.paned.sashpos, '')
self.assertRaises(Tkinter.TclError, self.paned.sashpos, 0)
self.assertRaises(tkinter.TclError, self.paned.sashpos, None)
self.assertRaises(tkinter.TclError, self.paned.sashpos, '')
self.assertRaises(tkinter.TclError, self.paned.sashpos, 0)
child = ttk.Label(self.paned, text='a')
self.paned.add(child, weight=1)
self.assertRaises(Tkinter.TclError, self.paned.sashpos, 0)
self.assertRaises(tkinter.TclError, self.paned.sashpos, 0)
child2 = ttk.Label(self.paned, text='b')
self.paned.add(child2)
self.assertRaises(Tkinter.TclError, self.paned.sashpos, 1)
self.assertRaises(tkinter.TclError, self.paned.sashpos, 1)
self.paned.pack(expand=True, fill='both')
self.paned.wait_visibility()
......@@ -714,7 +714,7 @@ class RadiobuttonTest(AbstractLabelTest, unittest.TestCase):
success.append(1)
return "cb test called"
myvar = Tkinter.IntVar()
myvar = tkinter.IntVar()
cbtn = ttk.Radiobutton(command=cb_test, variable=myvar, value=0)
cbtn2 = ttk.Radiobutton(command=cb_test, variable=myvar, value=1)
......@@ -759,7 +759,7 @@ class MenubuttonTest(AbstractLabelTest, unittest.TestCase):
def test_menu(self):
widget = self.create()
menu = Tkinter.Menu(widget, name='menu')
menu = tkinter.Menu(widget, name='menu')
self.checkParam(widget, 'menu', menu, conv=str)
menu.destroy()
......@@ -837,8 +837,8 @@ class ScaleTest(AbstractWidgetTest, unittest.TestCase):
self.scale['value'] = 30
self.assertEqual(self.scale.get(), self.scale['value'])
self.assertRaises(Tkinter.TclError, self.scale.get, '', 0)
self.assertRaises(Tkinter.TclError, self.scale.get, 0, '')
self.assertRaises(tkinter.TclError, self.scale.get, '', 0)
self.assertRaises(tkinter.TclError, self.scale.get, 0, '')
def test_set(self):
......@@ -857,7 +857,7 @@ class ScaleTest(AbstractWidgetTest, unittest.TestCase):
self.assertEqual(conv(self.scale.get()), min)
# changing directly the variable doesn't impose this limitation tho
var = Tkinter.DoubleVar()
var = tkinter.DoubleVar()
self.scale['variable'] = var
var.set(max + 5)
self.assertEqual(conv(self.scale.get()), var.get())
......@@ -874,7 +874,7 @@ class ScaleTest(AbstractWidgetTest, unittest.TestCase):
self.assertEqual(conv(self.scale.get(0, 0)), min)
self.assertEqual(conv(self.scale.get(self.scale.winfo_width(), 0)), max)
self.assertRaises(Tkinter.TclError, self.scale.set, None)
self.assertRaises(tkinter.TclError, self.scale.set, None)
@add_standard_options(StandardTtkOptionsTests)
......@@ -953,7 +953,7 @@ class NotebookTest(AbstractWidgetTest, unittest.TestCase):
def test_tab_identifiers(self):
self.nb.forget(0)
self.nb.hide(self.child2)
self.assertRaises(Tkinter.TclError, self.nb.tab, self.child1)
self.assertRaises(tkinter.TclError, self.nb.tab, self.child1)
self.assertEqual(self.nb.index('end'), 1)
self.nb.add(self.child2)
self.assertEqual(self.nb.index('end'), 1)
......@@ -974,7 +974,7 @@ class NotebookTest(AbstractWidgetTest, unittest.TestCase):
try:
if self.nb.tab('@%d, 5' % i, text=None) == 'a':
break
except Tkinter.TclError:
except tkinter.TclError:
pass
else:
......@@ -982,11 +982,11 @@ class NotebookTest(AbstractWidgetTest, unittest.TestCase):
def test_add_and_hidden(self):
self.assertRaises(Tkinter.TclError, self.nb.hide, -1)
self.assertRaises(Tkinter.TclError, self.nb.hide, 'hi')
self.assertRaises(Tkinter.TclError, self.nb.hide, None)
self.assertRaises(Tkinter.TclError, self.nb.add, None)
self.assertRaises(Tkinter.TclError, self.nb.add, ttk.Label(),
self.assertRaises(tkinter.TclError, self.nb.hide, -1)
self.assertRaises(tkinter.TclError, self.nb.hide, 'hi')
self.assertRaises(tkinter.TclError, self.nb.hide, None)
self.assertRaises(tkinter.TclError, self.nb.add, None)
self.assertRaises(tkinter.TclError, self.nb.add, ttk.Label(),
unknown='option')
tabs = self.nb.tabs()
......@@ -1011,9 +1011,9 @@ class NotebookTest(AbstractWidgetTest, unittest.TestCase):
def test_forget(self):
self.assertRaises(Tkinter.TclError, self.nb.forget, -1)
self.assertRaises(Tkinter.TclError, self.nb.forget, 'hi')
self.assertRaises(Tkinter.TclError, self.nb.forget, None)
self.assertRaises(tkinter.TclError, self.nb.forget, -1)
self.assertRaises(tkinter.TclError, self.nb.forget, 'hi')
self.assertRaises(tkinter.TclError, self.nb.forget, None)
tabs = self.nb.tabs()
child1_index = self.nb.index(self.child1)
......@@ -1027,8 +1027,8 @@ class NotebookTest(AbstractWidgetTest, unittest.TestCase):
def test_index(self):
self.assertRaises(Tkinter.TclError, self.nb.index, -1)
self.assertRaises(Tkinter.TclError, self.nb.index, None)
self.assertRaises(tkinter.TclError, self.nb.index, -1)
self.assertRaises(tkinter.TclError, self.nb.index, None)
self.assertIsInstance(self.nb.index('end'), int)
self.assertEqual(self.nb.index(self.child1), 0)
......@@ -1048,8 +1048,8 @@ class NotebookTest(AbstractWidgetTest, unittest.TestCase):
self.nb.insert('end', 0)
self.assertEqual(self.nb.tabs(), tabs)
# bad moves
self.assertRaises(Tkinter.TclError, self.nb.insert, 2, tabs[0])
self.assertRaises(Tkinter.TclError, self.nb.insert, -1, tabs[0])
self.assertRaises(tkinter.TclError, self.nb.insert, 2, tabs[0])
self.assertRaises(tkinter.TclError, self.nb.insert, -1, tabs[0])
# new tab
child3 = ttk.Label()
......@@ -1060,13 +1060,13 @@ class NotebookTest(AbstractWidgetTest, unittest.TestCase):
self.nb.insert(self.child1, child3)
self.assertEqual(self.nb.tabs(), (str(child3), ) + tabs)
self.nb.forget(child3)
self.assertRaises(Tkinter.TclError, self.nb.insert, 2, child3)
self.assertRaises(Tkinter.TclError, self.nb.insert, -1, child3)
self.assertRaises(tkinter.TclError, self.nb.insert, 2, child3)
self.assertRaises(tkinter.TclError, self.nb.insert, -1, child3)
# bad inserts
self.assertRaises(Tkinter.TclError, self.nb.insert, 'end', None)
self.assertRaises(Tkinter.TclError, self.nb.insert, None, 0)
self.assertRaises(Tkinter.TclError, self.nb.insert, None, None)
self.assertRaises(tkinter.TclError, self.nb.insert, 'end', None)
self.assertRaises(tkinter.TclError, self.nb.insert, None, 0)
self.assertRaises(tkinter.TclError, self.nb.insert, None, None)
def test_select(self):
......@@ -1090,9 +1090,9 @@ class NotebookTest(AbstractWidgetTest, unittest.TestCase):
def test_tab(self):
self.assertRaises(Tkinter.TclError, self.nb.tab, -1)
self.assertRaises(Tkinter.TclError, self.nb.tab, 'notab')
self.assertRaises(Tkinter.TclError, self.nb.tab, None)
self.assertRaises(tkinter.TclError, self.nb.tab, -1)
self.assertRaises(tkinter.TclError, self.nb.tab, 'notab')
self.assertRaises(tkinter.TclError, self.nb.tab, None)
self.assertIsInstance(self.nb.tab(self.child1), dict)
self.assertEqual(self.nb.tab(self.child1, text=None), 'a')
......@@ -1246,7 +1246,7 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
# child3 has child2 as parent, thus trying to set child2 as a children
# of child3 should result in an error
self.assertRaises(Tkinter.TclError,
self.assertRaises(tkinter.TclError,
self.tv.set_children, child3, child2)
# remove child2 children
......@@ -1272,20 +1272,20 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
self.assertEqual(self.tv.column('#0', width=None),
10 if self.wantobjects else '10')
# check read-only option
self.assertRaises(Tkinter.TclError, self.tv.column, '#0', id='X')
self.assertRaises(tkinter.TclError, self.tv.column, '#0', id='X')
self.assertRaises(Tkinter.TclError, self.tv.column, 'invalid')
self.assertRaises(tkinter.TclError, self.tv.column, 'invalid')
invalid_kws = [
{'unknown_option': 'some value'}, {'stretch': 'wrong'},
{'anchor': 'wrong'}, {'width': 'wrong'}, {'minwidth': 'wrong'}
]
for kw in invalid_kws:
self.assertRaises(Tkinter.TclError, self.tv.column, '#0',
self.assertRaises(tkinter.TclError, self.tv.column, '#0',
**kw)
def test_delete(self):
self.assertRaises(Tkinter.TclError, self.tv.delete, '#0')
self.assertRaises(tkinter.TclError, self.tv.delete, '#0')
item_id = self.tv.insert('', 'end')
item2 = self.tv.insert(item_id, 'end')
......@@ -1296,7 +1296,7 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
self.assertFalse(self.tv.get_children())
# reattach should fail
self.assertRaises(Tkinter.TclError,
self.assertRaises(tkinter.TclError,
self.tv.reattach, item_id, '', 'end')
# test multiple item delete
......@@ -1335,13 +1335,13 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
self.assertEqual(self.tv.get_children(item_id), ())
# bad values
self.assertRaises(Tkinter.TclError,
self.assertRaises(tkinter.TclError,
self.tv.reattach, 'nonexistent', '', 'end')
self.assertRaises(Tkinter.TclError,
self.assertRaises(tkinter.TclError,
self.tv.detach, 'nonexistent')
self.assertRaises(Tkinter.TclError,
self.assertRaises(tkinter.TclError,
self.tv.reattach, item2, 'otherparent', 'end')
self.assertRaises(Tkinter.TclError,
self.assertRaises(tkinter.TclError,
self.tv.reattach, item2, '', 'invalid')
# multiple detach
......@@ -1358,7 +1358,7 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
# the following will make a tk.call equivalent to
# tk.call(treeview, "exists") which should result in an error
# in the tcl interpreter since tk requires an item.
self.assertRaises(Tkinter.TclError, self.tv.exists, None)
self.assertRaises(tkinter.TclError, self.tv.exists, None)
def test_focus(self):
......@@ -1373,7 +1373,7 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
self.assertEqual(self.tv.focus(), '')
# try focusing inexistent item
self.assertRaises(Tkinter.TclError, self.tv.focus, 'hi')
self.assertRaises(tkinter.TclError, self.tv.focus, 'hi')
def test_heading(self):
......@@ -1386,10 +1386,10 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
self.assertEqual(self.tv.heading('#0', text=None), 'hi')
# invalid option
self.assertRaises(Tkinter.TclError, self.tv.heading, '#0',
self.assertRaises(tkinter.TclError, self.tv.heading, '#0',
background=None)
# invalid value
self.assertRaises(Tkinter.TclError, self.tv.heading, '#0',
self.assertRaises(tkinter.TclError, self.tv.heading, '#0',
anchor=1)
def test_heading_callback(self):
......@@ -1428,7 +1428,7 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
def test_index(self):
# item 'what' doesn't exist
self.assertRaises(Tkinter.TclError, self.tv.index, 'what')
self.assertRaises(tkinter.TclError, self.tv.index, 'what')
self.assertEqual(self.tv.index(''), 0)
......@@ -1454,30 +1454,30 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
# but it fails after item has been deleted
self.tv.delete(item1)
self.assertRaises(Tkinter.TclError, self.tv.index, c2)
self.assertRaises(tkinter.TclError, self.tv.index, c2)
def test_insert_item(self):
# parent 'none' doesn't exist
self.assertRaises(Tkinter.TclError, self.tv.insert, 'none', 'end')
self.assertRaises(tkinter.TclError, self.tv.insert, 'none', 'end')
# open values
self.assertRaises(Tkinter.TclError, self.tv.insert, '', 'end',
self.assertRaises(tkinter.TclError, self.tv.insert, '', 'end',
open='')
self.assertRaises(Tkinter.TclError, self.tv.insert, '', 'end',
self.assertRaises(tkinter.TclError, self.tv.insert, '', 'end',
open='please')
self.assertFalse(self.tv.delete(self.tv.insert('', 'end', open=True)))
self.assertFalse(self.tv.delete(self.tv.insert('', 'end', open=False)))
# invalid index
self.assertRaises(Tkinter.TclError, self.tv.insert, '', 'middle')
self.assertRaises(tkinter.TclError, self.tv.insert, '', 'middle')
# trying to duplicate item id is invalid
itemid = self.tv.insert('', 'end', 'first-item')
self.assertEqual(itemid, 'first-item')
self.assertRaises(Tkinter.TclError, self.tv.insert, '', 'end',
self.assertRaises(tkinter.TclError, self.tv.insert, '', 'end',
'first-item')
self.assertRaises(Tkinter.TclError, self.tv.insert, '', 'end',
self.assertRaises(tkinter.TclError, self.tv.insert, '', 'end',
MockTclObj('first-item'))
# unicode values
......@@ -1551,11 +1551,11 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
{'B': 123} if self.wantobjects else {'B': '123'})
# inexistent column
self.assertRaises(Tkinter.TclError, self.tv.set, item, 'A')
self.assertRaises(Tkinter.TclError, self.tv.set, item, 'A', 'b')
self.assertRaises(tkinter.TclError, self.tv.set, item, 'A')
self.assertRaises(tkinter.TclError, self.tv.set, item, 'A', 'b')
# inexistent item
self.assertRaises(Tkinter.TclError, self.tv.set, 'notme')
self.assertRaises(tkinter.TclError, self.tv.set, 'notme')
def test_tag_bind(self):
......@@ -1595,7 +1595,7 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
def test_tag_configure(self):
# Just testing parameter passing for now
self.assertRaises(TypeError, self.tv.tag_configure)
self.assertRaises(Tkinter.TclError, self.tv.tag_configure,
self.assertRaises(tkinter.TclError, self.tv.tag_configure,
'test', sky='blue')
self.tv.tag_configure('test', foreground='blue')
self.assertEqual(str(self.tv.tag_configure('test', 'foreground')),
......
......@@ -2,7 +2,7 @@
import unittest
import sys
import Tkinter
import Tkinter as tkinter
from ttk import setup_master, Scale
from test_ttk.support import (tcl_version, requires_tcl, get_tk_patchlevel,
pixels_conv, tcl_obj_eq)
......@@ -67,7 +67,7 @@ class AbstractWidgetTest(object):
expected = conv(expected)
if not self.wantobjects:
if isinstance(expected, tuple):
expected = Tkinter._join(expected)
expected = tkinter._join(expected)
else:
expected = str(expected)
if eq is None:
......@@ -85,7 +85,7 @@ class AbstractWidgetTest(object):
orig = widget[name]
if errmsg is not None:
errmsg = errmsg.format(value)
with self.assertRaises(Tkinter.TclError) as cm:
with self.assertRaises(tkinter.TclError) as cm:
widget[name] = value
if errmsg is not None:
self.assertEqual(str(cm.exception), errmsg)
......@@ -93,7 +93,7 @@ class AbstractWidgetTest(object):
self.assertEqual(widget[name], orig)
else:
widget[name] = orig
with self.assertRaises(Tkinter.TclError) as cm:
with self.assertRaises(tkinter.TclError) as cm:
widget.configure({name: value})
if errmsg is not None:
self.assertEqual(str(cm.exception), errmsg)
......@@ -212,7 +212,7 @@ class AbstractWidgetTest(object):
errmsg=errmsg)
def checkImageParam(self, widget, name):
image = Tkinter.PhotoImage('image1')
image = tkinter.PhotoImage('image1')
self.checkParam(widget, name, image, conv=str)
self.checkInvalidParam(widget, name, 'spam',
errmsg='image "spam" doesn\'t exist')
......@@ -433,7 +433,7 @@ class StandardOptionsTests(object):
def test_textvariable(self):
widget = self.create()
var = Tkinter.StringVar()
var = tkinter.StringVar()
self.checkVariableParam(widget, 'textvariable', var)
def test_troughcolor(self):
......@@ -494,7 +494,7 @@ class StandardOptionsTests(object):
def test_variable(self):
widget = self.create()
var = Tkinter.DoubleVar()
var = tkinter.DoubleVar()
self.checkVariableParam(widget, 'variable', var)
......@@ -543,5 +543,5 @@ def add_standard_options(*source_classes):
def setUpModule():
if test.test_support.verbose:
tcl = Tkinter.Tcl()
tcl = tkinter.Tcl()
print 'patchlevel =', tcl.call('info', 'patchlevel')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment