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
733d0f63
Commit
733d0f63
authored
Aug 07, 2017
by
Terry Jan Reedy
Committed by
GitHub
Aug 07, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-31130: IDLE -- stop leaks in test_configdialog. (#3016)
Initial patch by Victor Stinner.
parent
89225871
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
38 deletions
+50
-38
Lib/idlelib/configdialog.py
Lib/idlelib/configdialog.py
+1
-0
Lib/idlelib/idle_test/test_configdialog.py
Lib/idlelib/idle_test/test_configdialog.py
+48
-38
Misc/NEWS.d/next/IDLE/2017-08-07-14-02-56.bpo-31130.FbsC7f.rst
...NEWS.d/next/IDLE/2017-08-07-14-02-56.bpo-31130.FbsC7f.rst
+1
-0
No files found.
Lib/idlelib/configdialog.py
View file @
733d0f63
...
...
@@ -1856,6 +1856,7 @@ class VarTrace:
def
clear
(
self
):
"Clear lists (for tests)."
# Call after all tests in a module to avoid memory leaks.
self
.
untraced
.
clear
()
self
.
traced
.
clear
()
...
...
Lib/idlelib/idle_test/test_configdialog.py
View file @
733d0f63
...
...
@@ -9,7 +9,7 @@ requires('gui')
import
unittest
from
unittest
import
mock
from
idlelib.idle_test.mock_idle
import
Func
from
tkinter
import
Tk
,
Frame
,
IntVar
,
BooleanVar
,
DISABLED
,
NORMAL
from
tkinter
import
Tk
,
Frame
,
StringVar
,
IntVar
,
BooleanVar
,
DISABLED
,
NORMAL
from
idlelib
import
config
from
idlelib.configdialog
import
idleConf
,
changes
,
tracers
...
...
@@ -41,6 +41,8 @@ def tearDownModule():
global
root
,
dialog
idleConf
.
userCfg
=
usercfg
tracers
.
detach
()
tracers
.
clear
()
changes
.
clear
()
del
dialog
root
.
update_idletasks
()
root
.
destroy
()
...
...
@@ -442,16 +444,20 @@ class GenPageTest(unittest.TestCase):
class
VarTraceTest
(
unittest
.
TestCase
):
@
classmethod
def
setUpClass
(
cls
):
cls
.
tracers
=
configdialog
.
VarTrace
()
cls
.
iv
=
IntVar
(
root
)
cls
.
bv
=
BooleanVar
(
root
)
@
classmethod
def
tearDownClass
(
cls
):
del
cls
.
tracers
,
cls
.
iv
,
cls
.
bv
def
setUp
(
self
):
changes
.
clear
()
tracers
.
clear
()
self
.
v1
=
IntVar
(
root
)
self
.
v2
=
BooleanVar
(
root
)
self
.
tracers
.
clear
()
self
.
called
=
0
def
tearDown
(
self
):
del
self
.
v1
,
self
.
v2
def
var_changed_increment
(
self
,
*
params
):
self
.
called
+=
13
...
...
@@ -459,64 +465,68 @@ class VarTraceTest(unittest.TestCase):
pass
def
test_init
(
self
):
tracers
.
__init__
()
self
.
assertEqual
(
tracers
.
untraced
,
[])
self
.
assertEqual
(
tracers
.
traced
,
[])
tr
=
self
.
tracers
tr
.
__init__
()
self
.
assertEqual
(
tr
.
untraced
,
[])
self
.
assertEqual
(
tr
.
traced
,
[])
def
test_clear
(
self
):
tracers
.
untraced
.
append
(
0
)
tracers
.
traced
.
append
(
1
)
tracers
.
clear
()
self
.
assertEqual
(
tracers
.
untraced
,
[])
self
.
assertEqual
(
tracers
.
traced
,
[])
tr
=
self
.
tracers
tr
.
untraced
.
append
(
0
)
tr
.
traced
.
append
(
1
)
tr
.
clear
()
self
.
assertEqual
(
tr
.
untraced
,
[])
self
.
assertEqual
(
tr
.
traced
,
[])
def
test_add
(
self
):
tr
=
tracers
tr
=
self
.
tracers
func
=
Func
()
cb
=
tr
.
make_callback
=
mock
.
Mock
(
return_value
=
func
)
v1
=
tr
.
add
(
self
.
v1
,
self
.
var_changed_increment
)
self
.
assertIs
Instance
(
v1
,
IntVar
)
v2
=
tr
.
add
(
self
.
v2
,
self
.
var_changed_boolean
)
self
.
assertIs
Instance
(
v2
,
BooleanVar
)
iv
=
tr
.
add
(
self
.
iv
,
self
.
var_changed_increment
)
self
.
assertIs
(
iv
,
self
.
iv
)
bv
=
tr
.
add
(
self
.
bv
,
self
.
var_changed_boolean
)
self
.
assertIs
(
bv
,
self
.
bv
)
v3
=
IntVar
(
root
)
v3
=
tr
.
add
(
v3
,
(
'main'
,
'section'
,
'option'
))
sv
=
StringVar
(
root
)
sv2
=
tr
.
add
(
sv
,
(
'main'
,
'section'
,
'option'
))
self
.
assertIs
(
sv2
,
sv
)
cb
.
assert_called_once
()
cb
.
assert_called_with
(
v3
,
(
'main'
,
'section'
,
'option'
))
cb
.
assert_called_with
(
sv
,
(
'main'
,
'section'
,
'option'
))
expected
=
[(
v1
,
self
.
var_changed_increment
),
(
v2
,
self
.
var_changed_boolean
),
(
v3
,
func
)]
expected
=
[(
iv
,
self
.
var_changed_increment
),
(
bv
,
self
.
var_changed_boolean
),
(
sv
,
func
)]
self
.
assertEqual
(
tr
.
traced
,
[])
self
.
assertEqual
(
tr
.
untraced
,
expected
)
del
tr
.
make_callback
def
test_make_callback
(
self
):
cb
=
tracers
.
make_callback
(
self
.
v1
,
(
'main'
,
'section'
,
'option'
))
cb
=
self
.
tracers
.
make_callback
(
self
.
iv
,
(
'main'
,
'section'
,
'option'
))
self
.
assertTrue
(
callable
(
cb
))
self
.
v1
.
set
(
42
)
self
.
iv
.
set
(
42
)
# Not attached, so set didn't invoke the callback.
self
.
assertNotIn
(
'section'
,
changes
[
'main'
])
# Invoke callback manually.
cb
()
self
.
assertIn
(
'section'
,
changes
[
'main'
])
self
.
assertEqual
(
changes
[
'main'
][
'section'
][
'option'
],
'42'
)
changes
.
clear
()
def
test_attach_detach
(
self
):
tr
=
tracers
v1
=
tr
.
add
(
self
.
v1
,
self
.
var_changed_increment
)
v2
=
tr
.
add
(
self
.
v2
,
self
.
var_changed_boolean
)
expected
=
[(
v1
,
self
.
var_changed_increment
),
(
v2
,
self
.
var_changed_boolean
)]
tr
=
self
.
tracers
iv
=
tr
.
add
(
self
.
iv
,
self
.
var_changed_increment
)
bv
=
tr
.
add
(
self
.
bv
,
self
.
var_changed_boolean
)
expected
=
[(
iv
,
self
.
var_changed_increment
),
(
bv
,
self
.
var_changed_boolean
)]
# Attach callbacks and test call increment.
tr
.
attach
()
self
.
assertEqual
(
tr
.
untraced
,
[])
self
.
assertCountEqual
(
tr
.
traced
,
expected
)
v1
.
set
(
1
)
self
.
assertEqual
(
v1
.
get
(),
1
)
iv
.
set
(
1
)
self
.
assertEqual
(
iv
.
get
(),
1
)
self
.
assertEqual
(
self
.
called
,
13
)
# Check that only one callback is attached to a variable.
...
...
@@ -524,7 +534,7 @@ class VarTraceTest(unittest.TestCase):
# would be called twice and the counter would be 2.
self
.
called
=
0
tr
.
attach
()
v1
.
set
(
1
)
iv
.
set
(
1
)
self
.
assertEqual
(
self
.
called
,
13
)
# Detach callbacks.
...
...
@@ -532,7 +542,7 @@ class VarTraceTest(unittest.TestCase):
tr
.
detach
()
self
.
assertEqual
(
tr
.
traced
,
[])
self
.
assertCountEqual
(
tr
.
untraced
,
expected
)
v1
.
set
(
1
)
iv
.
set
(
1
)
self
.
assertEqual
(
self
.
called
,
0
)
...
...
Misc/NEWS.d/next/IDLE/2017-08-07-14-02-56.bpo-31130.FbsC7f.rst
0 → 100644
View file @
733d0f63
IDLE -- stop leaks in test_configdialog. Initial patch by Victor Stinner.
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