Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
95cf9862
Commit
95cf9862
authored
Aug 21, 2014
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Import Tkinter as tkinter to help merging and avoid backporting errors.
parent
c208fe67
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
214 additions
and
214 deletions
+214
-214
Lib/lib-tk/test/test_tkinter/test_font.py
Lib/lib-tk/test/test_tkinter/test_font.py
+2
-2
Lib/lib-tk/test/test_tkinter/test_geometry_managers.py
Lib/lib-tk/test/test_tkinter/test_geometry_managers.py
+45
-45
Lib/lib-tk/test/test_tkinter/test_text.py
Lib/lib-tk/test/test_tkinter/test_text.py
+6
-6
Lib/lib-tk/test/test_tkinter/test_widgets.py
Lib/lib-tk/test/test_tkinter/test_widgets.py
+38
-38
Lib/lib-tk/test/test_ttk/support.py
Lib/lib-tk/test/test_ttk/support.py
+6
-6
Lib/lib-tk/test/test_ttk/test_extensions.py
Lib/lib-tk/test/test_ttk/test_extensions.py
+15
-15
Lib/lib-tk/test/test_ttk/test_style.py
Lib/lib-tk/test/test_ttk/test_style.py
+4
-4
Lib/lib-tk/test/test_ttk/test_widgets.py
Lib/lib-tk/test/test_ttk/test_widgets.py
+90
-90
Lib/lib-tk/test/widget_tests.py
Lib/lib-tk/test/widget_tests.py
+8
-8
No files found.
Lib/lib-tk/test/test_tkinter/test_font.py
View file @
95cf9862
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
T
kinter
.
_tkinter
.
TclError
:
except
t
kinter
.
_tkinter
.
TclError
:
f
=
font
.
Font
(
name
=
fontname
,
exists
=
False
)
font1
=
font
.
nametofont
(
fontname
)
font2
=
font
.
nametofont
(
fontname
)
...
...
Lib/lib-tk/test/test_tkinter/test_geometry_managers.py
View file @
95cf9862
This diff is collapsed.
Click to expand it.
Lib/lib-tk/test/test_tkinter/test_text.py
View file @
95cf9862
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
=
T
kinter
.
Text
(
self
.
root
)
self
.
text
=
t
kinter
.
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
(
T
kinter
.
TclError
,
text
.
search
,
None
,
'1.0'
)
self
.
assertRaises
(
T
kinter
.
TclError
,
text
.
search
,
'a'
,
None
)
self
.
assertRaises
(
T
kinter
.
TclError
,
text
.
search
,
None
,
None
)
self
.
assertRaises
(
t
kinter
.
TclError
,
text
.
search
,
None
,
'1.0'
)
self
.
assertRaises
(
t
kinter
.
TclError
,
text
.
search
,
'a'
,
None
)
self
.
assertRaises
(
t
kinter
.
TclError
,
text
.
search
,
None
,
None
)
# Invalid text index.
self
.
assertRaises
(
T
kinter
.
TclError
,
text
.
search
,
''
,
0
)
self
.
assertRaises
(
t
kinter
.
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.
...
...
Lib/lib-tk/test/test_tkinter/test_widgets.py
View file @
95cf9862
This diff is collapsed.
Click to expand it.
Lib/lib-tk/test/test_ttk/support.py
View file @
95cf9862
import
unittest
import
Tkinter
import
Tkinter
as
tkinter
def
get_tk_root
():
try
:
root
=
T
kinter
.
_default_root
root
=
t
kinter
.
_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
=
T
kinter
.
Tk
()
root
=
t
kinter
.
Tk
()
return
root
...
...
@@ -45,7 +45,7 @@ _tk_patchlevel = None
def
get_tk_patchlevel
():
global
_tk_patchlevel
if
_tk_patchlevel
is
None
:
tcl
=
T
kinter
.
Tcl
()
tcl
=
t
kinter
.
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
,
T
kinter
.
Widget
)):
if
isinstance
(
expected
,
(
str
,
T
kinter
.
Widget
)):
if
isinstance
(
actual
,
(
str
,
t
kinter
.
Widget
)):
if
isinstance
(
expected
,
(
str
,
t
kinter
.
Widget
)):
return
str
(
actual
)
==
str
(
expected
)
return
False
Lib/lib-tk/test/test_ttk/test_extensions.py
View file @
95cf9862
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
(
T
kinter
.
TclError
,
x
.
tk
.
globalgetvar
,
var
)
self
.
assertRaises
(
t
kinter
.
TclError
,
x
.
tk
.
globalgetvar
,
var
)
# manually created variable
myvar
=
T
kinter
.
DoubleVar
()
myvar
=
t
kinter
.
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
(
T
kinter
.
TclError
,
x
.
tk
.
globalgetvar
,
name
)
self
.
assertRaises
(
t
kinter
.
TclError
,
x
.
tk
.
globalgetvar
,
name
)
# checking that the tracing callback is properly removed
myvar
=
T
kinter
.
IntVar
()
myvar
=
t
kinter
.
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
,
T
kinter
.
TclError
)
self
.
assertNotEqual
(
sys
.
last_type
,
t
kinter
.
TclError
)
def
test_initialization
(
self
):
# master passing
x
=
ttk
.
LabeledScale
()
self
.
assertEqual
(
x
.
master
,
T
kinter
.
_default_root
)
self
.
assertEqual
(
x
.
master
,
t
kinter
.
_default_root
)
x
.
destroy
()
master
=
T
kinter
.
Frame
()
master
=
t
kinter
.
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
=
T
kinter
.
DoubleVar
(
value
=
20
)
myvar
=
t
kinter
.
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
(
T
kinter
.
TclError
,
ttk
.
LabeledScale
,
a
=
'b'
)
self
.
assertRaises
(
t
kinter
.
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
=
T
kinter
.
StringVar
()
self
.
textvar
=
t
kinter
.
StringVar
()
def
tearDown
(
self
):
del
self
.
textvar
...
...
@@ -202,18 +202,18 @@ class OptionMenuTest(unittest.TestCase):
def
test_widget_destroy
(
self
):
var
=
T
kinter
.
StringVar
()
var
=
t
kinter
.
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
(
T
kinter
.
TclError
,
optmenu
.
tk
.
globalgetvar
,
name
)
self
.
assertRaises
(
t
kinter
.
TclError
,
optmenu
.
tk
.
globalgetvar
,
name
)
def
test_initialization
(
self
):
self
.
assertRaises
(
T
kinter
.
TclError
,
self
.
assertRaises
(
t
kinter
.
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
(
T
kinter
.
TclError
,
optmenu
[
'menu'
].
invoke
,
-
1
)
self
.
assertRaises
(
t
kinter
.
TclError
,
optmenu
[
'menu'
].
invoke
,
-
1
)
self
.
assertEqual
(
optmenu
.
_variable
.
get
(),
items
[
0
])
optmenu
.
destroy
()
...
...
Lib/lib-tk/test/test_ttk/test_style.py
View file @
95cf9862
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
(
T
kinter
.
TclError
,
style
.
layout
,
'NotALayout'
)
self
.
assertRaises
(
t
kinter
.
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
(
T
kinter
.
TclError
,
style
.
layout
,
'Treeview'
,
self
.
assertRaises
(
t
kinter
.
TclError
,
style
.
layout
,
'Treeview'
,
[(
'name'
,
{
'option'
:
'inexistent'
})])
def
test_theme_use
(
self
):
self
.
assertRaises
(
T
kinter
.
TclError
,
self
.
style
.
theme_use
,
self
.
assertRaises
(
t
kinter
.
TclError
,
self
.
style
.
theme_use
,
'nonexistingname'
)
curr_theme
=
self
.
style
.
theme_use
()
...
...
Lib/lib-tk/test/test_ttk/test_widgets.py
View file @
95cf9862
This diff is collapsed.
Click to expand it.
Lib/lib-tk/test/widget_tests.py
View file @
95cf9862
...
...
@@ -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
=
T
kinter
.
_join
(
expected
)
expected
=
t
kinter
.
_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
(
T
kinter
.
TclError
)
as
cm
:
with
self
.
assertRaises
(
t
kinter
.
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
(
T
kinter
.
TclError
)
as
cm
:
with
self
.
assertRaises
(
t
kinter
.
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
=
T
kinter
.
PhotoImage
(
'image1'
)
image
=
t
kinter
.
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
=
T
kinter
.
StringVar
()
var
=
t
kinter
.
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
=
T
kinter
.
DoubleVar
()
var
=
t
kinter
.
DoubleVar
()
self
.
checkVariableParam
(
widget
,
'variable'
,
var
)
...
...
@@ -543,5 +543,5 @@ def add_standard_options(*source_classes):
def
setUpModule
():
if
test
.
test_support
.
verbose
:
tcl
=
T
kinter
.
Tcl
()
tcl
=
t
kinter
.
Tcl
()
print
'patchlevel ='
,
tcl
.
call
(
'info'
,
'patchlevel'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment