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
c0ed707b
Commit
c0ed707b
authored
Jun 09, 2015
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #24408: Added more tkinter.Font tests.
parent
d0040711
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
5 deletions
+65
-5
Lib/tkinter/test/test_tkinter/test_font.py
Lib/tkinter/test/test_tkinter/test_font.py
+65
-5
No files found.
Lib/tkinter/test/test_tkinter/test_font.py
View file @
c0ed707b
...
...
@@ -6,14 +6,54 @@ from tkinter.test.support import AbstractTkTest
requires
(
'gui'
)
fontname
=
"TkDefaultFont"
class
FontTest
(
AbstractTkTest
,
unittest
.
TestCase
):
def
test_font_eq
(
self
):
fontname
=
"TkDefaultFont"
@
classmethod
def
setUpClass
(
cls
):
AbstractTkTest
.
setUpClass
()
try
:
f
=
font
.
Font
(
root
=
self
.
root
,
name
=
fontname
,
exists
=
True
)
except
tkinter
.
_tkinter
.
TclError
:
f
=
font
.
Font
(
root
=
self
.
root
,
name
=
fontname
,
exists
=
False
)
cls
.
font
=
font
.
Font
(
root
=
cls
.
root
,
name
=
fontname
,
exists
=
True
)
except
tkinter
.
TclError
:
cls
.
font
=
font
.
Font
(
root
=
cls
.
root
,
name
=
fontname
,
exists
=
False
)
def
test_configure
(
self
):
options
=
self
.
font
.
configure
()
self
.
assertGreaterEqual
(
set
(
options
),
{
'family'
,
'size'
,
'weight'
,
'slant'
,
'underline'
,
'overstrike'
})
for
key
in
options
:
self
.
assertEqual
(
self
.
font
.
cget
(
key
),
options
[
key
])
self
.
assertEqual
(
self
.
font
[
key
],
options
[
key
])
for
key
in
'family'
,
'weight'
,
'slant'
:
self
.
assertIsInstance
(
options
[
key
],
str
)
self
.
assertIsInstance
(
self
.
font
.
cget
(
key
),
str
)
self
.
assertIsInstance
(
self
.
font
[
key
],
str
)
sizetype
=
int
if
self
.
wantobjects
else
str
for
key
in
'size'
,
'underline'
,
'overstrike'
:
self
.
assertIsInstance
(
options
[
key
],
sizetype
)
self
.
assertIsInstance
(
self
.
font
.
cget
(
key
),
sizetype
)
self
.
assertIsInstance
(
self
.
font
[
key
],
sizetype
)
def
test_actual
(
self
):
options
=
self
.
font
.
actual
()
self
.
assertGreaterEqual
(
set
(
options
),
{
'family'
,
'size'
,
'weight'
,
'slant'
,
'underline'
,
'overstrike'
})
for
key
in
options
:
self
.
assertEqual
(
self
.
font
.
actual
(
key
),
options
[
key
])
for
key
in
'family'
,
'weight'
,
'slant'
:
self
.
assertIsInstance
(
options
[
key
],
str
)
self
.
assertIsInstance
(
self
.
font
.
actual
(
key
),
str
)
sizetype
=
int
if
self
.
wantobjects
else
str
for
key
in
'size'
,
'underline'
,
'overstrike'
:
self
.
assertIsInstance
(
options
[
key
],
sizetype
)
self
.
assertIsInstance
(
self
.
font
.
actual
(
key
),
sizetype
)
def
test_name
(
self
):
self
.
assertEqual
(
self
.
font
.
name
,
fontname
)
self
.
assertEqual
(
str
(
self
.
font
),
fontname
)
def
test_eq
(
self
):
font1
=
font
.
Font
(
root
=
self
.
root
,
name
=
fontname
,
exists
=
True
)
font2
=
font
.
Font
(
root
=
self
.
root
,
name
=
fontname
,
exists
=
True
)
self
.
assertIsNot
(
font1
,
font2
)
...
...
@@ -21,6 +61,26 @@ class FontTest(AbstractTkTest, unittest.TestCase):
self
.
assertNotEqual
(
font1
,
font1
.
copy
())
self
.
assertNotEqual
(
font1
,
0
)
def
test_measure
(
self
):
self
.
assertIsInstance
(
self
.
font
.
measure
(
'abc'
),
int
)
def
test_metrics
(
self
):
metrics
=
self
.
font
.
metrics
()
self
.
assertGreaterEqual
(
set
(
metrics
),
{
'ascent'
,
'descent'
,
'linespace'
,
'fixed'
})
for
key
in
metrics
:
self
.
assertEqual
(
self
.
font
.
metrics
(
key
),
metrics
[
key
])
self
.
assertIsInstance
(
metrics
[
key
],
int
)
self
.
assertIsInstance
(
self
.
font
.
metrics
(
key
),
int
)
def
test_families
(
self
):
families
=
font
.
families
(
self
.
root
)
self
.
assertIn
(
self
.
font
.
actual
(
'family'
),
families
)
def
test_names
(
self
):
names
=
font
.
names
(
self
.
root
)
self
.
assertIn
(
fontname
,
names
)
tests_gui
=
(
FontTest
,
)
if
__name__
==
"__main__"
:
...
...
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