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
b96ebd4f
Kaydet (Commit)
b96ebd4f
authored
May 16, 2014
tarafından
Terry Jan Reedy
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge with 3.4
üst
0dfce56c
6936159d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
29 deletions
+32
-29
htest.py
Lib/idlelib/idle_test/htest.py
+32
-29
No files found.
Lib/idlelib/idle_test/htest.py
Dosyayı görüntüle @
b96ebd4f
'''Run
a human test of Idle wndow, dialog, and other widget classe
s.
'''Run
human tests of Idle's window, dialog, and popup widget
s.
run(klass) runs a test for one class.
runall() runs all the defined tests
run(test): run *test*, a callable that causes a widget to be displayed.
runall(): run all tests defined in this file.
Let X be a global name bound to a widget callable. End the module with
The file wih the widget class should end with
if __name__ == '__main__':
<unittest, if there is one>
from idlelib.idle_test.htest import run
run(X)
where X is a global object of the module. X must be a callable with a
.__name__ attribute that accepts a 'parent' attribute. X will usually be
a widget class, but a callable instance with .__name__ or a wrapper
function also work. The name of wrapper functions, like _Editor_Window,
should start with '_'.
This file must then contain an instance of this template.
The X object must have a .__name__ attribute and a 'parent' parameter.
X will often be a widget class, but a callable instance with .__name__
or a wrapper function also work. The name of wrapper functions, like
'_Editor_Window', should start with '_'.
This file must contain a matching instance of the folling template,
with X.__name__ prepended, as in '_Editor_window_spec ...'.
_spec = {
'file': '',
'kwds': {'title': ''},
'msg': ""
}
with X.__name__ prepended to _spec.
File (no .py) is used in runall() to import the file and get the class.
Kwds is passed to X (**kwds) after 'parent' is added, to initialize X.
Msg. displayed is a window with a start button. hint as to how the user
might test the widget. Closing The box skips or ends the test.
file (no .py): used in runall() to import the file and get X.
kwds: passed to X (**kwds), after 'parent' is added, to initialize X.
title: an example; used for some widgets, delete if not.
msg: displayed in a master window. Hints as to how the user might
test the widget. Close the window to skip or end the test.
'''
from
importlib
import
import_module
import
tkinter
as
tk
# Template for class_spec dicts, copy and uncomment
_Editor_window_spec
=
{
'file'
:
'EditorWindow'
,
...
...
@@ -61,30 +64,30 @@ GetCfgSectionNameDialog_spec = {
"Close 'Get Name' with a valid entry (printed to Shell), [Cancel], or [X]"
,
}
def
run
(
klas
):
"
Test the widget class klas using
_spec dict"
def
run
(
test
):
"
Display a widget with callable *test* using a
_spec dict"
root
=
tk
.
Tk
()
klas_spec
=
globals
()[
klas
.
__name__
+
'_spec'
]
klas_kwds
=
klas
_spec
[
'kwds'
]
klas
_kwds
[
'parent'
]
=
root
# This presumes that Idle consistently uses 'parent'
def
run_
klas
():
widget
=
klas
(
**
klas
_kwds
)
test_spec
=
globals
()[
test
.
__name__
+
'_spec'
]
test_kwds
=
test
_spec
[
'kwds'
]
test
_kwds
[
'parent'
]
=
root
def
run_
test
():
widget
=
test
(
**
test
_kwds
)
try
:
print
(
widget
.
result
)
except
AttributeError
:
pass
tk
.
Label
(
root
,
text
=
klas
_spec
[
'msg'
],
justify
=
'left'
)
.
pack
()
tk
.
Button
(
root
,
text
=
'Test '
+
klas
.
__name__
,
command
=
run_klas
)
.
pack
()
tk
.
Label
(
root
,
text
=
test
_spec
[
'msg'
],
justify
=
'left'
)
.
pack
()
tk
.
Button
(
root
,
text
=
'Test '
+
test
.
__name__
,
command
=
run_test
)
.
pack
()
root
.
mainloop
()
def
runall
():
'Run all tests. Quick and dirty version.'
"Run all tests. Quick and dirty version."
for
k
,
d
in
globals
()
.
items
():
if
k
.
endswith
(
'_spec'
):
mod
=
import_module
(
'idlelib.'
+
d
[
'file'
])
klas
=
getattr
(
mod
,
k
[:
-
5
])
run
(
klas
)
test
=
getattr
(
mod
,
k
[:
-
5
])
run
(
test
)
if
__name__
==
'__main__'
:
runall
()
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