Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
054e0914
Kaydet (Commit)
054e0914
authored
May 21, 2017
tarafından
mlouielu
Kaydeden (comit)
terryjreedy
May 21, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-30290: IDLE: Add more tests for help_about dialog (#1697)
Increases coverage to 99%
üst
81755471
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
99 additions
and
28 deletions
+99
-28
help_about.py
Lib/idlelib/help_about.py
+36
-28
test_help_about.py
Lib/idlelib/idle_test/test_help_about.py
+63
-0
No files found.
Lib/idlelib/help_about.py
Dosyayı görüntüle @
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,7 +36,12 @@ class AboutDialog(Toplevel):
self
.
buttonOk
.
focus_set
()
self
.
bind
(
'<Return>'
,
self
.
Ok
)
#dismiss dialog
self
.
bind
(
'<Escape>'
,
self
.
Ok
)
#dismiss dialog
self
.
wait_window
()
self
.
_current_textview
=
None
self
.
_utest
=
_utest
if
not
_utest
:
self
.
deiconify
()
self
.
wait_window
()
def
CreateWidgets
(
self
):
release
=
version
[:
version
.
index
(
' '
)]
...
...
@@ -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
,
highlightbackground
=
self
.
bg
,
command
=
self
.
ShowLicense
)
buttonLicense
.
pack
(
side
=
LEFT
,
padx
=
10
,
pady
=
10
)
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
,
highlightbackground
=
self
.
bg
,
command
=
self
.
ShowPythonCredits
)
buttonCredits
.
pack
(
side
=
LEFT
,
padx
=
10
,
pady
=
10
)
self
.
buttonLicense
=
Button
(
py_button_f
,
text
=
'License'
,
width
=
8
,
highlightbackground
=
self
.
bg
,
command
=
self
.
ShowLicense
)
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
)
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
)
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
,
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
,
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
,
highlightbackground
=
self
.
bg
,
command
=
self
.
ShowIDLECredits
)
idle_credits_b
.
pack
(
side
=
LEFT
,
padx
=
10
,
pady
=
10
)
self
.
idle_about_b
=
Button
(
idle_button_f
,
text
=
'README'
,
width
=
8
,
highlightbackground
=
self
.
bg
,
command
=
self
.
ShowIDLEAbout
)
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
)
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
)
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
Dosyayı görüntüle @
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