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
054e0914
Commit
054e0914
authored
May 22, 2017
by
mlouielu
Committed by
terryjreedy
May 21, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-30290: IDLE: Add more tests for help_about dialog (#1697)
Increases coverage to 99%
parent
81755471
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
99 additions
and
28 deletions
+99
-28
Lib/idlelib/help_about.py
Lib/idlelib/help_about.py
+36
-28
Lib/idlelib/idle_test/test_help_about.py
Lib/idlelib/idle_test/test_help_about.py
+63
-0
No files found.
Lib/idlelib/help_about.py
View file @
054e0914
...
...
@@ -13,9 +13,10 @@ class AboutDialog(Toplevel):
"""Modal about dialog for idle
"""
def
__init__
(
self
,
parent
,
title
,
_htest
=
False
):
def
__init__
(
self
,
parent
,
title
,
_htest
=
False
,
_utest
=
False
):
"""
_htest - bool, change box location when running htest
_utest - bool, don't wait_window when running unittest
"""
Toplevel
.
__init__
(
self
,
parent
)
self
.
configure
(
borderwidth
=
5
)
...
...
@@ -35,6 +36,11 @@ class AboutDialog(Toplevel):
self
.
buttonOk
.
focus_set
()
self
.
bind
(
'<Return>'
,
self
.
Ok
)
#dismiss dialog
self
.
bind
(
'<Escape>'
,
self
.
Ok
)
#dismiss dialog
self
.
_current_textview
=
None
self
.
_utest
=
_utest
if
not
_utest
:
self
.
deiconify
()
self
.
wait_window
()
def
CreateWidgets
(
self
):
...
...
@@ -80,18 +86,18 @@ class AboutDialog(Toplevel):
labelTkVer
.
grid
(
row
=
9
,
column
=
1
,
sticky
=
W
,
padx
=
2
,
pady
=
0
)
py_button_f
=
Frame
(
frameBg
,
bg
=
self
.
bg
)
py_button_f
.
grid
(
row
=
10
,
column
=
0
,
columnspan
=
2
,
sticky
=
NSEW
)
buttonLicense
=
Button
(
py_button_f
,
text
=
'License'
,
width
=
8
,
self
.
buttonLicense
=
Button
(
py_button_f
,
text
=
'License'
,
width
=
8
,
highlightbackground
=
self
.
bg
,
command
=
self
.
ShowLicense
)
buttonLicense
.
pack
(
side
=
LEFT
,
padx
=
10
,
pady
=
10
)
buttonCopyright
=
Button
(
py_button_f
,
text
=
'Copyright'
,
width
=
8
,
self
.
buttonLicense
.
pack
(
side
=
LEFT
,
padx
=
10
,
pady
=
10
)
self
.
buttonCopyright
=
Button
(
py_button_f
,
text
=
'Copyright'
,
width
=
8
,
highlightbackground
=
self
.
bg
,
command
=
self
.
ShowCopyright
)
buttonCopyright
.
pack
(
side
=
LEFT
,
padx
=
10
,
pady
=
10
)
buttonCredits
=
Button
(
py_button_f
,
text
=
'Credits'
,
width
=
8
,
self
.
buttonCopyright
.
pack
(
side
=
LEFT
,
padx
=
10
,
pady
=
10
)
self
.
buttonCredits
=
Button
(
py_button_f
,
text
=
'Credits'
,
width
=
8
,
highlightbackground
=
self
.
bg
,
command
=
self
.
ShowPythonCredits
)
buttonCredits
.
pack
(
side
=
LEFT
,
padx
=
10
,
pady
=
10
)
self
.
buttonCredits
.
pack
(
side
=
LEFT
,
padx
=
10
,
pady
=
10
)
Frame
(
frameBg
,
borderwidth
=
1
,
relief
=
SUNKEN
,
height
=
2
,
bg
=
self
.
bg
).
grid
(
row
=
11
,
column
=
0
,
sticky
=
EW
,
columnspan
=
3
,
padx
=
5
,
pady
=
5
)
...
...
@@ -100,18 +106,18 @@ class AboutDialog(Toplevel):
idle_v
.
grid
(
row
=
12
,
column
=
0
,
sticky
=
W
,
padx
=
10
,
pady
=
0
)
idle_button_f
=
Frame
(
frameBg
,
bg
=
self
.
bg
)
idle_button_f
.
grid
(
row
=
13
,
column
=
0
,
columnspan
=
3
,
sticky
=
NSEW
)
idle_about_b
=
Button
(
idle_button_f
,
text
=
'README'
,
width
=
8
,
self
.
idle_about_b
=
Button
(
idle_button_f
,
text
=
'README'
,
width
=
8
,
highlightbackground
=
self
.
bg
,
command
=
self
.
ShowIDLEAbout
)
idle_about_b
.
pack
(
side
=
LEFT
,
padx
=
10
,
pady
=
10
)
idle_news_b
=
Button
(
idle_button_f
,
text
=
'NEWS'
,
width
=
8
,
self
.
idle_about_b
.
pack
(
side
=
LEFT
,
padx
=
10
,
pady
=
10
)
self
.
idle_news_b
=
Button
(
idle_button_f
,
text
=
'NEWS'
,
width
=
8
,
highlightbackground
=
self
.
bg
,
command
=
self
.
ShowIDLENEWS
)
idle_news_b
.
pack
(
side
=
LEFT
,
padx
=
10
,
pady
=
10
)
idle_credits_b
=
Button
(
idle_button_f
,
text
=
'Credits'
,
width
=
8
,
self
.
idle_news_b
.
pack
(
side
=
LEFT
,
padx
=
10
,
pady
=
10
)
self
.
idle_credits_b
=
Button
(
idle_button_f
,
text
=
'Credits'
,
width
=
8
,
highlightbackground
=
self
.
bg
,
command
=
self
.
ShowIDLECredits
)
idle_credits_b
.
pack
(
side
=
LEFT
,
padx
=
10
,
pady
=
10
)
self
.
idle_credits_b
.
pack
(
side
=
LEFT
,
padx
=
10
,
pady
=
10
)
# License, et all, are of type _sitebuiltins._Printer
def
ShowLicense
(
self
):
...
...
@@ -137,11 +143,13 @@ class AboutDialog(Toplevel):
def
display_printer_text
(
self
,
title
,
printer
):
printer
.
_Printer__setup
()
text
=
'
\
n
'
.
join
(
printer
.
_Printer__lines
)
textview
.
view_text
(
self
,
title
,
text
)
self
.
_current_textview
=
textview
.
view_text
(
self
,
title
,
text
,
_utest
=
self
.
_utest
)
def
display_file_text
(
self
,
title
,
filename
,
encoding
=
None
):
fn
=
os
.
path
.
join
(
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
)),
filename
)
textview
.
view_file
(
self
,
title
,
fn
,
encoding
)
self
.
_current_textview
=
textview
.
view_file
(
self
,
title
,
fn
,
encoding
,
_utest
=
self
.
_utest
)
def
Ok
(
self
,
event
=
None
):
self
.
destroy
()
...
...
Lib/idlelib/idle_test/test_help_about.py
View file @
054e0914
...
...
@@ -6,8 +6,12 @@ from idlelib import help_about
from
idlelib
import
textview
from
idlelib.idle_test.mock_idle
import
Func
from
idlelib.idle_test.mock_tk
import
Mbox_func
from
test.support
import
requires
,
findfile
requires
(
'gui'
)
from
tkinter
import
Tk
import
unittest
About
=
help_about
.
AboutDialog
class
Dummy_about_dialog
():
# Dummy class for testing file display functions.
...
...
@@ -16,6 +20,65 @@ class Dummy_about_dialog():
idle_news
=
About
.
ShowIDLENEWS
# Called by the above
display_file_text
=
About
.
display_file_text
_utest
=
True
class
AboutDialogTest
(
unittest
.
TestCase
):
@
classmethod
def
setUpClass
(
cls
):
cls
.
root
=
Tk
()
cls
.
root
.
withdraw
()
cls
.
dialog
=
About
(
cls
.
root
,
'About IDLE'
,
_utest
=
True
)
@
classmethod
def
tearDownClass
(
cls
):
del
cls
.
dialog
cls
.
root
.
update_idletasks
()
cls
.
root
.
destroy
()
del
cls
.
root
def
tearDown
(
self
):
if
self
.
dialog
.
_current_textview
:
self
.
dialog
.
_current_textview
.
destroy
()
def
test_dialog_title
(
self
):
"""This will test about dialog title"""
self
.
assertEqual
(
self
.
dialog
.
title
(),
'About IDLE'
)
def
test_printer_dialog
(
self
):
"""This will test dialog which using printer"""
buttons
=
[(
license
,
self
.
dialog
.
buttonLicense
),
(
copyright
,
self
.
dialog
.
buttonCopyright
),
(
credits
,
self
.
dialog
.
buttonCredits
)]
for
printer
,
button
in
buttons
:
dialog
=
self
.
dialog
printer
.
_Printer__setup
()
button
.
invoke
()
self
.
assertEqual
(
printer
.
_Printer__lines
[
0
],
dialog
.
_current_textview
.
textView
.
get
(
'1.0'
,
'1.end'
))
self
.
assertEqual
(
printer
.
_Printer__lines
[
1
],
dialog
.
_current_textview
.
textView
.
get
(
'2.0'
,
'2.end'
))
dialog
.
_current_textview
.
destroy
()
def
test_file_dialog
(
self
):
"""This will test dialog which using file"""
buttons
=
[(
'README.txt'
,
self
.
dialog
.
idle_about_b
),
(
'NEWS.txt'
,
self
.
dialog
.
idle_news_b
),
(
'CREDITS.txt'
,
self
.
dialog
.
idle_credits_b
)]
for
filename
,
button
in
buttons
:
dialog
=
self
.
dialog
button
.
invoke
()
fn
=
findfile
(
filename
,
subdir
=
'idlelib'
)
with
open
(
fn
)
as
f
:
self
.
assertEqual
(
f
.
readline
().
strip
(),
dialog
.
_current_textview
.
textView
.
get
(
'1.0'
,
'1.end'
))
f
.
readline
()
self
.
assertEqual
(
f
.
readline
().
strip
(),
dialog
.
_current_textview
.
textView
.
get
(
'3.0'
,
'3.end'
))
dialog
.
_current_textview
.
destroy
()
class
DisplayFileTest
(
unittest
.
TestCase
):
...
...
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