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
092473ee
Kaydet (Commit)
092473ee
authored
May 18, 2016
tarafından
Terry Jan Reedy
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #21939: Test IDLE percolator. Original patch by Saimadhav Heblikar.
üst
cec95813
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
145 additions
and
26 deletions
+145
-26
Percolator.py
Lib/idlelib/Percolator.py
+25
-24
test_parenmatch.py
Lib/idlelib/idle_test/test_parenmatch.py
+2
-2
test_percolator.py
Lib/idlelib/idle_test/test_percolator.py
+118
-0
No files found.
Lib/idlelib/Percolator.py
Dosyayı görüntüle @
092473ee
from
idlelib.WidgetRedirector
import
WidgetRedirector
from
idlelib.Delegator
import
Delegator
class
Percolator
:
def
__init__
(
self
,
text
):
...
...
@@ -16,8 +17,10 @@ class Percolator:
while
self
.
top
is
not
self
.
bottom
:
self
.
removefilter
(
self
.
top
)
self
.
top
=
None
self
.
bottom
.
setdelegate
(
None
);
self
.
bottom
=
None
self
.
redir
.
close
();
self
.
redir
=
None
self
.
bottom
.
setdelegate
(
None
)
self
.
bottom
=
None
self
.
redir
.
close
()
self
.
redir
=
None
self
.
text
=
None
def
insert
(
self
,
index
,
chars
,
tags
=
None
):
...
...
@@ -51,54 +54,52 @@ class Percolator:
f
.
setdelegate
(
filter
.
delegate
)
filter
.
setdelegate
(
None
)
def
_percolator
(
parent
):
def
_percolator
(
parent
):
# htest #
import
tkinter
as
tk
import
re
class
Tracer
(
Delegator
):
def
__init__
(
self
,
name
):
self
.
name
=
name
Delegator
.
__init__
(
self
,
None
)
def
insert
(
self
,
*
args
):
print
(
self
.
name
,
": insert"
,
args
)
self
.
delegate
.
insert
(
*
args
)
def
delete
(
self
,
*
args
):
print
(
self
.
name
,
": delete"
,
args
)
self
.
delegate
.
delete
(
*
args
)
root
=
tk
.
Tk
()
root
.
title
(
"Test Percolator"
)
box
=
tk
.
Toplevel
(
parent
)
box
.
title
(
"Test Percolator"
)
width
,
height
,
x
,
y
=
list
(
map
(
int
,
re
.
split
(
'[x+]'
,
parent
.
geometry
())))
root
.
geometry
(
"+
%
d+
%
d"
%
(
x
,
y
+
150
))
text
=
tk
.
Text
(
root
)
box
.
geometry
(
"+
%
d+
%
d"
%
(
x
,
y
+
150
))
text
=
tk
.
Text
(
box
)
p
=
Percolator
(
text
)
pin
=
p
.
insertfilter
pout
=
p
.
removefilter
t1
=
Tracer
(
"t1"
)
t2
=
Tracer
(
"t2"
)
def
toggle1
():
if
var1
.
get
()
==
0
:
var1
.
set
(
1
)
p
.
insertfilter
(
t1
)
elif
var1
.
get
()
==
1
:
var1
.
set
(
0
)
p
.
removefilter
(
t1
)
(
pin
if
var1
.
get
()
else
pout
)(
t1
)
def
toggle2
():
if
var2
.
get
()
==
0
:
var2
.
set
(
1
)
p
.
insertfilter
(
t2
)
elif
var2
.
get
()
==
1
:
var2
.
set
(
0
)
p
.
removefilter
(
t2
)
(
pin
if
var2
.
get
()
else
pout
)(
t2
)
text
.
pack
()
var1
=
tk
.
IntVar
()
cb1
=
tk
.
Checkbutton
(
root
,
text
=
"Tracer1"
,
command
=
toggle1
,
variable
=
var1
)
cb1
=
tk
.
Checkbutton
(
box
,
text
=
"Tracer1"
,
command
=
toggle1
,
variable
=
var1
)
cb1
.
pack
()
var2
=
tk
.
IntVar
()
cb2
=
tk
.
Checkbutton
(
root
,
text
=
"Tracer2"
,
command
=
toggle2
,
variable
=
var2
)
cb2
=
tk
.
Checkbutton
(
box
,
text
=
"Tracer2"
,
command
=
toggle2
,
variable
=
var2
)
cb2
.
pack
()
root
.
mainloop
()
if
__name__
==
"__main__"
:
import
unittest
unittest
.
main
(
'idlelib.idle_test.test_percolator'
,
verbosity
=
2
,
exit
=
False
)
from
idlelib.idle_test.htest
import
run
run
(
_percolator
)
Lib/idlelib/idle_test/test_parenmatch.py
Dosyayı görüntüle @
092473ee
"""Test idlelib.ParenMatch."""
# This must currently be a gui test because ParenMatch methods use
# several text methods not defined on idlelib.idle_test.mock_tk.Text.
from
test.support
import
requires
requires
(
'gui'
)
import
unittest
from
unittest.mock
import
Mock
from
test.support
import
requires
from
tkinter
import
Tk
,
Text
from
idlelib.ParenMatch
import
ParenMatch
...
...
@@ -20,7 +21,6 @@ class ParenMatchTest(unittest.TestCase):
@classmethod
def
setUpClass
(
cls
):
requires
(
'gui'
)
cls
.
root
=
Tk
()
cls
.
text
=
Text
(
cls
.
root
)
cls
.
editwin
=
DummyEditwin
(
cls
.
text
)
...
...
Lib/idlelib/idle_test/test_percolator.py
0 → 100644
Dosyayı görüntüle @
092473ee
'''Test Percolator'''
from
test.support
import
requires
requires
(
'gui'
)
import
unittest
from
tkinter
import
Text
,
Tk
,
END
from
idlelib.Percolator
import
Percolator
,
Delegator
class
MyFilter
(
Delegator
):
def
__init__
(
self
):
Delegator
.
__init__
(
self
,
None
)
def
insert
(
self
,
*
args
):
self
.
insert_called_with
=
args
self
.
delegate
.
insert
(
*
args
)
def
delete
(
self
,
*
args
):
self
.
delete_called_with
=
args
self
.
delegate
.
delete
(
*
args
)
def
uppercase_insert
(
self
,
index
,
chars
,
tags
=
None
):
chars
=
chars
.
upper
()
self
.
delegate
.
insert
(
index
,
chars
)
def
lowercase_insert
(
self
,
index
,
chars
,
tags
=
None
):
chars
=
chars
.
lower
()
self
.
delegate
.
insert
(
index
,
chars
)
def
dont_insert
(
self
,
index
,
chars
,
tags
=
None
):
pass
class
PercolatorTest
(
unittest
.
TestCase
):
@classmethod
def
setUpClass
(
cls
):
cls
.
root
=
Tk
()
cls
.
text
=
Text
(
cls
.
root
)
@classmethod
def
tearDownClass
(
cls
):
cls
.
text
.
destroy
()
cls
.
root
.
destroy
()
del
cls
.
text
,
cls
.
root
def
setUp
(
self
):
self
.
percolator
=
Percolator
(
self
.
text
)
self
.
filter_one
=
MyFilter
()
self
.
filter_two
=
MyFilter
()
self
.
percolator
.
insertfilter
(
self
.
filter_one
)
self
.
percolator
.
insertfilter
(
self
.
filter_two
)
def
tearDown
(
self
):
self
.
percolator
.
close
()
self
.
text
.
delete
(
'1.0'
,
END
)
def
test_insertfilter
(
self
):
self
.
assertIsNotNone
(
self
.
filter_one
.
delegate
)
self
.
assertEqual
(
self
.
percolator
.
top
,
self
.
filter_two
)
self
.
assertEqual
(
self
.
filter_two
.
delegate
,
self
.
filter_one
)
self
.
assertEqual
(
self
.
filter_one
.
delegate
,
self
.
percolator
.
bottom
)
def
test_removefilter
(
self
):
filter_three
=
MyFilter
()
self
.
percolator
.
removefilter
(
self
.
filter_two
)
self
.
assertEqual
(
self
.
percolator
.
top
,
self
.
filter_one
)
self
.
assertIsNone
(
self
.
filter_two
.
delegate
)
filter_three
=
MyFilter
()
self
.
percolator
.
insertfilter
(
self
.
filter_two
)
self
.
percolator
.
insertfilter
(
filter_three
)
self
.
percolator
.
removefilter
(
self
.
filter_one
)
self
.
assertEqual
(
self
.
percolator
.
top
,
filter_three
)
self
.
assertEqual
(
filter_three
.
delegate
,
self
.
filter_two
)
self
.
assertEqual
(
self
.
filter_two
.
delegate
,
self
.
percolator
.
bottom
)
self
.
assertIsNone
(
self
.
filter_one
.
delegate
)
def
test_insert
(
self
):
self
.
text
.
insert
(
'insert'
,
'foo'
)
self
.
assertEqual
(
self
.
text
.
get
(
'1.0'
,
END
),
'foo
\n
'
)
self
.
assertTupleEqual
(
self
.
filter_one
.
insert_called_with
,
(
'insert'
,
'foo'
,
None
))
def
test_modify_insert
(
self
):
self
.
filter_one
.
insert
=
self
.
filter_one
.
uppercase_insert
self
.
text
.
insert
(
'insert'
,
'bAr'
)
self
.
assertEqual
(
self
.
text
.
get
(
'1.0'
,
END
),
'BAR
\n
'
)
def
test_modify_chain_insert
(
self
):
filter_three
=
MyFilter
()
self
.
percolator
.
insertfilter
(
filter_three
)
self
.
filter_two
.
insert
=
self
.
filter_two
.
uppercase_insert
self
.
filter_one
.
insert
=
self
.
filter_one
.
lowercase_insert
self
.
text
.
insert
(
'insert'
,
'BaR'
)
self
.
assertEqual
(
self
.
text
.
get
(
'1.0'
,
END
),
'bar
\n
'
)
def
test_dont_insert
(
self
):
self
.
filter_one
.
insert
=
self
.
filter_one
.
dont_insert
self
.
text
.
insert
(
'insert'
,
'foo bar'
)
self
.
assertEqual
(
self
.
text
.
get
(
'1.0'
,
END
),
'
\n
'
)
self
.
filter_one
.
insert
=
self
.
filter_one
.
dont_insert
self
.
text
.
insert
(
'insert'
,
'foo bar'
)
self
.
assertEqual
(
self
.
text
.
get
(
'1.0'
,
END
),
'
\n
'
)
def
test_without_filter
(
self
):
self
.
text
.
insert
(
'insert'
,
'hello'
)
self
.
assertEqual
(
self
.
text
.
get
(
'1.0'
,
'end'
),
'hello
\n
'
)
def
test_delete
(
self
):
self
.
text
.
insert
(
'insert'
,
'foo'
)
self
.
text
.
delete
(
'1.0'
,
'1.2'
)
self
.
assertEqual
(
self
.
text
.
get
(
'1.0'
,
END
),
'o
\n
'
)
self
.
assertTupleEqual
(
self
.
filter_one
.
delete_called_with
,
(
'1.0'
,
'1.2'
))
if
__name__
==
'__main__'
:
unittest
.
main
(
verbosity
=
2
)
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