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
75cbeb5d
Commit
75cbeb5d
authored
Jun 03, 2016
by
Terry Jan Reedy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue 20567: Revise idle_test/README.txt and some tests to match new advice.
parent
1ef8c7e8
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
39 additions
and
34 deletions
+39
-34
Lib/idlelib/idle_test/README.txt
Lib/idlelib/idle_test/README.txt
+16
-12
Lib/idlelib/idle_test/test_autocomplete.py
Lib/idlelib/idle_test/test_autocomplete.py
+1
-2
Lib/idlelib/idle_test/test_autoexpand.py
Lib/idlelib/idle_test/test_autoexpand.py
+1
-1
Lib/idlelib/idle_test/test_formatparagraph.py
Lib/idlelib/idle_test/test_formatparagraph.py
+1
-2
Lib/idlelib/idle_test/test_percolator.py
Lib/idlelib/idle_test/test_percolator.py
+2
-2
Lib/idlelib/idle_test/test_replacedialog.py
Lib/idlelib/idle_test/test_replacedialog.py
+2
-1
Lib/idlelib/idle_test/test_textview.py
Lib/idlelib/idle_test/test_textview.py
+2
-1
Lib/idlelib/idle_test/test_undodelegator.py
Lib/idlelib/idle_test/test_undodelegator.py
+2
-1
Lib/idlelib/idle_test/test_widgetredir.py
Lib/idlelib/idle_test/test_widgetredir.py
+12
-12
No files found.
Lib/idlelib/idle_test/README.txt
View file @
75cbeb5d
...
@@ -56,40 +56,44 @@ requires('gui')
...
@@ -56,40 +56,44 @@ requires('gui')
To guard a test class, put "requires('gui')" in its setUpClass function.
To guard a test class, put "requires('gui')" in its setUpClass function.
To avoid interfering with other
GUI tests, all GUI objects must be
To avoid interfering with other
gui tests, all gui objects must be destroyed and
de
stroyed and deleted by the end of the test. Widgets, such as a Tk
de
leted by the end of the test. The Tk root created in a setUpX function should
root, created in a setUpX function, should be destroyed in th
e
be destroyed in the corresponding tearDownX and the module or class attribut
e
corresponding tearDownX. Module and class widget attributes should also
deleted. Others widgets should descend from the single root and the attributes
be deleted
.
deleted BEFORE root is destroyed. See https://bugs.python.org/issue20567
.
@classmethod
@classmethod
def setUpClass(cls):
def setUpClass(cls):
requires('gui')
requires('gui')
cls.root = tk.Tk()
cls.root = tk.Tk()
cls.text = tk.Text(root)
@classmethod
@classmethod
def tearDownClass(cls):
def tearDownClass(cls):
del cls.text
cls.root.destroy()
cls.root.destroy()
del cls.root
del cls.root
Requires('gui') causes the test(s) it guards to be skipped if any of
Requires('gui') causes the test(s) it guards to be skipped if any of
a few
conditions are met:
these
conditions are met:
- The tests are being run by regrtest.py, and it was started without
- The tests are being run by regrtest.py, and it was started without
enabling the "gui" resource with the "-u" command line option.
enabling the "gui" resource with the "-u" command line option.
- The tests are being run on Windows by a service that is not allowed
- The tests are being run on Windows by a service that is not allowed
to interact with the graphical environment.
to interact with the graphical environment.
- The tests are being run on Linux and X Windows is not available.
- The tests are being run on Mac OSX in a process that cannot make a
- The tests are being run on Mac OSX in a process that cannot make a
window manager connection.
window manager connection.
- tkinter.Tk cannot be successfully instantiated for some reason.
- tkinter.Tk cannot be successfully instantiated for some reason.
- test.support.use_resources has been set by something other than
- test.support.use_resources has been set by something other than
regrtest.py and does not contain "gui".
regrtest.py and does not contain "gui".
Tests of non-GUI operations should avoid creating tk widgets. Incidental
Tests of non-GUI operations should avoid creating tk widgets. Incidental
uses of tk variables and messageboxes can be replaced by the mock
uses of tk variables and messageboxes can be replaced by the mock
classes in idle_test/mock_tk.py. The mock text handles some uses of the
classes in idle_test/mock_tk.py. The mock text handles some uses of the
...
...
Lib/idlelib/idle_test/test_autocomplete.py
View file @
75cbeb5d
...
@@ -33,9 +33,8 @@ class AutoCompleteTest(unittest.TestCase):
...
@@ -33,9 +33,8 @@ class AutoCompleteTest(unittest.TestCase):
@
classmethod
@
classmethod
def
tearDownClass
(
cls
):
def
tearDownClass
(
cls
):
del
cls
.
editor
,
cls
.
text
cls
.
root
.
destroy
()
cls
.
root
.
destroy
()
del
cls
.
text
del
cls
.
editor
del
cls
.
root
del
cls
.
root
def
setUp
(
self
):
def
setUp
(
self
):
...
...
Lib/idlelib/idle_test/test_autoexpand.py
View file @
75cbeb5d
...
@@ -25,10 +25,10 @@ class AutoExpandTest(unittest.TestCase):
...
@@ -25,10 +25,10 @@ class AutoExpandTest(unittest.TestCase):
@
classmethod
@
classmethod
def
tearDownClass
(
cls
):
def
tearDownClass
(
cls
):
del
cls
.
text
,
cls
.
auto_expand
if
hasattr
(
cls
,
'tk'
):
if
hasattr
(
cls
,
'tk'
):
cls
.
tk
.
destroy
()
cls
.
tk
.
destroy
()
del
cls
.
tk
del
cls
.
tk
del
cls
.
text
,
cls
.
auto_expand
def
tearDown
(
self
):
def
tearDown
(
self
):
self
.
text
.
delete
(
'1.0'
,
'end'
)
self
.
text
.
delete
(
'1.0'
,
'end'
)
...
...
Lib/idlelib/idle_test/test_formatparagraph.py
View file @
75cbeb5d
...
@@ -276,10 +276,9 @@ class FormatEventTest(unittest.TestCase):
...
@@ -276,10 +276,9 @@ class FormatEventTest(unittest.TestCase):
@
classmethod
@
classmethod
def
tearDownClass
(
cls
):
def
tearDownClass
(
cls
):
del
cls
.
text
,
cls
.
formatter
cls
.
root
.
destroy
()
cls
.
root
.
destroy
()
del
cls
.
root
del
cls
.
root
del
cls
.
text
del
cls
.
formatter
def
test_short_line
(
self
):
def
test_short_line
(
self
):
self
.
text
.
insert
(
'1.0'
,
"Short line
\
n
"
)
self
.
text
.
insert
(
'1.0'
,
"Short line
\
n
"
)
...
...
Lib/idlelib/idle_test/test_percolator.py
View file @
75cbeb5d
...
@@ -40,9 +40,9 @@ class PercolatorTest(unittest.TestCase):
...
@@ -40,9 +40,9 @@ class PercolatorTest(unittest.TestCase):
@
classmethod
@
classmethod
def
tearDownClass
(
cls
):
def
tearDownClass
(
cls
):
cls
.
text
.
destroy
()
del
cls
.
text
cls
.
root
.
destroy
()
cls
.
root
.
destroy
()
del
cls
.
text
,
cls
.
root
del
cls
.
root
def
setUp
(
self
):
def
setUp
(
self
):
self
.
percolator
=
Percolator
(
self
.
text
)
self
.
percolator
=
Percolator
(
self
.
text
)
...
...
Lib/idlelib/idle_test/test_replacedialog.py
View file @
75cbeb5d
...
@@ -31,8 +31,9 @@ class ReplaceDialogTest(unittest.TestCase):
...
@@ -31,8 +31,9 @@ class ReplaceDialogTest(unittest.TestCase):
@
classmethod
@
classmethod
def
tearDownClass
(
cls
):
def
tearDownClass
(
cls
):
se
.
tkMessageBox
=
orig_mbox
se
.
tkMessageBox
=
orig_mbox
del
cls
.
text
,
cls
.
dialog
,
cls
.
engine
cls
.
root
.
destroy
()
cls
.
root
.
destroy
()
del
cls
.
text
,
cls
.
dialog
,
cls
.
engine
,
cls
.
root
del
cls
.
root
def
setUp
(
self
):
def
setUp
(
self
):
self
.
text
.
insert
(
'insert'
,
'This is a sample sTring'
)
self
.
text
.
insert
(
'insert'
,
'This is a sample sTring'
)
...
...
Lib/idlelib/idle_test/test_textview.py
View file @
75cbeb5d
...
@@ -22,7 +22,8 @@ def setUpModule():
...
@@ -22,7 +22,8 @@ def setUpModule():
root
=
Tk
()
root
=
Tk
()
def
tearDownModule
():
def
tearDownModule
():
global
root
global
root
,
TV
del
TV
root
.
destroy
()
# pyflakes falsely sees root as undefined
root
.
destroy
()
# pyflakes falsely sees root as undefined
del
root
del
root
...
...
Lib/idlelib/idle_test/test_undodelegator.py
View file @
75cbeb5d
...
@@ -23,8 +23,9 @@ class UndoDelegatorTest(unittest.TestCase):
...
@@ -23,8 +23,9 @@ class UndoDelegatorTest(unittest.TestCase):
@
classmethod
@
classmethod
def
tearDownClass
(
cls
):
def
tearDownClass
(
cls
):
cls
.
percolator
.
redir
.
close
()
cls
.
percolator
.
redir
.
close
()
del
cls
.
percolator
,
cls
.
text
cls
.
root
.
destroy
()
cls
.
root
.
destroy
()
del
cls
.
percolator
,
cls
.
text
,
cls
.
root
del
cls
.
root
def
setUp
(
self
):
def
setUp
(
self
):
self
.
delegator
=
UndoDelegator
()
self
.
delegator
=
UndoDelegator
()
...
...
Lib/idlelib/idle_test/test_widgetredir.py
View file @
75cbeb5d
...
@@ -14,14 +14,14 @@ class InitCloseTest(unittest.TestCase):
...
@@ -14,14 +14,14 @@ class InitCloseTest(unittest.TestCase):
@
classmethod
@
classmethod
def
setUpClass
(
cls
):
def
setUpClass
(
cls
):
requires
(
'gui'
)
requires
(
'gui'
)
cls
.
tk
=
Tk
()
cls
.
root
=
Tk
()
cls
.
text
=
Text
(
cls
.
tk
)
cls
.
text
=
Text
(
cls
.
root
)
@
classmethod
@
classmethod
def
tearDownClass
(
cls
):
def
tearDownClass
(
cls
):
cls
.
text
.
destroy
()
del
cls
.
text
cls
.
tk
.
destroy
()
cls
.
root
.
destroy
()
del
cls
.
text
,
cls
.
tk
del
cls
.
root
def
test_init
(
self
):
def
test_init
(
self
):
redir
=
WidgetRedirector
(
self
.
text
)
redir
=
WidgetRedirector
(
self
.
text
)
...
@@ -43,14 +43,14 @@ class WidgetRedirectorTest(unittest.TestCase):
...
@@ -43,14 +43,14 @@ class WidgetRedirectorTest(unittest.TestCase):
@
classmethod
@
classmethod
def
setUpClass
(
cls
):
def
setUpClass
(
cls
):
requires
(
'gui'
)
requires
(
'gui'
)
cls
.
tk
=
Tk
()
cls
.
root
=
Tk
()
cls
.
text
=
Text
(
cls
.
tk
)
cls
.
text
=
Text
(
cls
.
root
)
@
classmethod
@
classmethod
def
tearDownClass
(
cls
):
def
tearDownClass
(
cls
):
cls
.
text
.
destroy
()
del
cls
.
text
cls
.
tk
.
destroy
()
cls
.
root
.
destroy
()
del
cls
.
text
,
cls
.
tk
del
cls
.
root
def
setUp
(
self
):
def
setUp
(
self
):
self
.
redir
=
WidgetRedirector
(
self
.
text
)
self
.
redir
=
WidgetRedirector
(
self
.
text
)
...
@@ -108,13 +108,13 @@ class WidgetRedirectorTest(unittest.TestCase):
...
@@ -108,13 +108,13 @@ class WidgetRedirectorTest(unittest.TestCase):
def
test_command_dispatch
(
self
):
def
test_command_dispatch
(
self
):
# Test that .__init__ causes redirection of tk calls
# Test that .__init__ causes redirection of tk calls
# through redir.dispatch
# through redir.dispatch
self
.
tk
.
call
(
self
.
text
.
_w
,
'insert'
,
'hello'
)
self
.
root
.
call
(
self
.
text
.
_w
,
'insert'
,
'hello'
)
self
.
assertEqual
(
self
.
func
.
args
,
(
'hello'
,))
self
.
assertEqual
(
self
.
func
.
args
,
(
'hello'
,))
self
.
assertEqual
(
self
.
text
.
get
(
'1.0'
,
'end'
),
'
\
n
'
)
self
.
assertEqual
(
self
.
text
.
get
(
'1.0'
,
'end'
),
'
\
n
'
)
# Ensure that called through redir .dispatch and not through
# Ensure that called through redir .dispatch and not through
# self.text.insert by having mock raise TclError.
# self.text.insert by having mock raise TclError.
self
.
func
.
__init__
(
TclError
())
self
.
func
.
__init__
(
TclError
())
self
.
assertEqual
(
self
.
tk
.
call
(
self
.
text
.
_w
,
'insert'
,
'boo'
),
''
)
self
.
assertEqual
(
self
.
root
.
call
(
self
.
text
.
_w
,
'insert'
,
'boo'
),
''
)
...
...
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