8000 Merge branch 'main' into patch-112672 · python/cpython@feb8c90 · GitHub
[go: up one dir, main page]

Skip to content

Commit feb8c90

Browse files
authored
Merge branch 'main' into patch-112672
2 parents f15bf1a + 23e001f commit feb8c90

27 files changed

+89
-60
lines changed

Lib/idlelib/browser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ def closure():
250250
class Nested_in_closure: pass
251251
ModuleBrowser(parent, file, _htest=True)
252252

253+
253254
if __name__ == "__main__":
254255
if len(sys.argv) == 1: # If pass file on command line, unittest fails.
255256
from unittest import main

Lib/idlelib/calltip_w.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ def calltip_hide(event):
193193

194194
text.focus_set()
195195

196+
196197
if __name__ == '__main__':
197198
from unittest import main
198199
main('idlelib.idle_test.test_calltip_w', verbosity=2, exit=False)

Lib/idlelib/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,7 @@ def dumpCfg(cfg):
906906
dumpCfg(idleConf.userCfg)
907907
print('\nlines = ', line, ', crc = ', crc, sep='')
908908

909+
909910
if __name__ == '__main__':
910911
from unittest import main
911912
main('idlelib.idle_test.test_config', verbosity=2, exit=False)

Lib/idlelib/debugobj.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ def _debug_object_browser(parent): # htest #
135135
node = TreeNode(sc.canvas, None, item)
136136
node.update()
137137

138+
138139
if __name__ == '__main__':
139140
from unittest import main
140141
main('idlelib.idle_test.test_debugobj', verbosity=2, exit=False)

Lib/idlelib/delegator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def setdelegate(self, delegate):
2828
self.resetcache()
2929
self.delegate = delegate
3030

31+
3132
if __name__ == '__main__':
3233
from unittest import main
3334
main('idlelib.idle_test.test_delegator', verbosity=2)

Lib/idlelib/dynoption.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def SetMenu(self,valueList,value=None):
2929
if value:
3030
self.variable.set(value)
3131

32+
3233
def _dyn_option_menu(parent): # htest #
3334
from tkinter import Toplevel # + StringVar, Button
3435

@@ -49,6 +50,7 @@ def update():
4950
button = Button(top, text="Change option set", command=update)
5051
button.pack()
5152

53+
5254
if __name__ == '__main__':
5355
# Only module without unittests because of intention to replace.
5456
from idlelib.idle_test.htest import run

Lib/idlelib/editor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,6 +1748,7 @@ def _editor_window(parent): # htest #
17481748
# Does not stop error, neither does following
17491749
# edit.text.bind("<<close-window>>", edit.close_event)
17501750

1751+
17511752
if __name__ == '__main__':
17521753
from unittest import main
17531754
main('idlelib.idle_test.test_editor', verbosity=2, exit=False)

Lib/idlelib/filelist.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def _test(): # TODO check and convert to htest
124124
if flist.inversedict:
125125
root.mainloop()
126126

127+
127128
if __name__ == '__main__':
128129
from unittest import main
129130
main('idlelib.idle_test.test_filelist', verbosity=2)

Lib/idlelib/grep.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,17 @@ def _grep_dialog(parent): # htest #
204204
frame.pack()
205205
text = Text(frame, height=5)
206206
text.pack()
207+
text.insert('1.0', 'import grep')
207208

208209
def show_grep_dialog():
209-
text.tag_add(SEL, "1.0", END)
210+
text.tag_add(SEL, "1.0", '1.end')
210211
grep(text, flist=flist)
211-
text.tag_remove(SEL, "1.0", END)
212+
text.tag_remove(SEL, "1.0", '1.end')
212213

213214
button = Button(frame, text="Show GrepDialog", command=show_grep_dialog)
214215
button.pack()
215216

217+
216218
if __name__ == "__main__":
217219
from unittest import main
218220
main('idlelib.idle_test.test_grep', verbosity=2, exit=False)

Lib/idlelib/help.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,17 +278,19 @@ def copy_strip():
278278
out.write(line.rstrip() + b'\n')
279279
print(f'{src} copied to {dst}')
280280

281-
def show_idlehelp(parent):
281+
282+
def _helpwindow(parent):
282283
"Create HelpWindow; called from Idle Help event handler."
283284
filename = join(abspath(dirname(__file__)), 'help.html')
284285
if not isfile(filename):
285286
# Try copy_strip, present message.
286287
return
287288
HelpWindow(parent, filename, 'IDLE Help (%s)' % python_version())
288289

290+
289291
if __name__ == '__main__':
290292
from unittest import main
291293
main('idlelib.idle_test.test_help', verbosity=2, exit=False)
292294

293295
from idlelib.idle_test.htest import run
294-
run(show_idlehelp)
296+
run(_helpwindow)

Lib/idlelib/idle_test/htest.py

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@
170170
'msg': "Click the 'Show GrepDialog' button.\n"
171171
"Test the various 'Find-in-files' functions.\n"
172172
"The results should be displayed in a new '*Output*' window.\n"
173-
"'Right-click'->'Go to file/line' anywhere in the search results "
174-
"should open that file \nin a new EditorWindow."
173+
"'Right-click'->'Go to file/line' in the search results\n "
174+
"should open that file in a new EditorWindow."
175175
}
176176

177177
HelpSource_spec = {
@@ -190,6 +190,13 @@
190190
"<Escape>, [Cancel], or [X] prints None to shell"
191191
}
192192

193+
_helpwindow_spec = {
194+
'file': 'help',
195+
'kwds': {},
196+
'msg': "If the help text displays, this works.\n"
197+
"Text is selectable. Window is scrollable."
198+
}
199+
193200
_io_binding_spec = {
194201
'file': 'iomenu',
195202
'kwds': {},
@@ -203,26 +210,6 @@
203210
"Check that changes were saved by opening the file elsewhere."
204211
}
205212

206-
_linenumbers_drag_scrolling_spec = {
207-
'file': 'sidebar',
208-
'kwds': {},
209-
'msg': textwrap.dedent("""\
210-
1. Click on the line numbers and drag down below the edge of the
211-
window, moving the mouse a bit and then leaving it there for a
212-
while. The text and line numbers should gradually scroll down,
213-
with the selection updated continuously.
214-
215-
2. With the lines still selected, click on a line number above
216-
or below the selected lines. Only the line whose number was
217-
clicked should be selected.
218-
219-
3. Repeat step #1, dragging to above the window. The text and
220-
line numbers should gradually scroll up, with the selection
221-
updated continuously.
222-
223-
4. Repeat step #2, clicking a line number below the selection."""),
224-
}
225-
226213
_multi_call_spec = {
227214
'file': 'multicall',
228215
'kwds': {},
@@ -288,6 +275,15 @@
288275
"Click [Close] or [X] to close the 'Replace Dialog'."
289276
}
290277

278+
_scrolled_list_spec = {
279+
'file': 'scrolledlist',
280+
'kwds': {},
281+
'msg': "You should see a scrollable list of items\n"
282+
"Selecting (clicking) or double clicking an item "
283+
"prints the name to the console or Idle shell.\n"
284+
"Right clicking an item will display a popup."
285+
}
286+
291287
_search_dialog_spec = {
292288
10000 'file': 'search',
293289
'kwds': {},
@@ -303,28 +299,31 @@
303299
"Its only action is to close."
304300
}
305301

306-
_scrolled_list_spec = {
307-
'file': 'scrolledlist',
302+
_sidebar_number_scrolling_spec = {
303+
'file': 'sidebar',
308304
'kwds': {},
309-
'msg': "You should see a scrollable list of items\n"
310-
"Selecting (clicking) or double clicking an item "
311-
"prints the name to the console or Idle shell.\n"
312-
"Right clicking an item will display a popup."
313-
}
305+
'msg': textwrap.dedent("""\
306+
1. Click on the line numbers and drag down below the edge of the
307+
window, moving the mouse a bit and then leaving it there for a
308+
while. The text and line numbers should gradually scroll down,
309+
with the selection updated continuously.
314310
315-
show_idlehelp_spec = {
316-
'file': 'help',
317-
'kwds': {},
318-
'msg': "If the help text displays, this works.\n"
319-
"Text is selectable. Window is scrollable."
311+
2. With the lines still selected, click on a line number above
312+
or below the selected lines. Only the line whose number was
313+
clicked should be selected.
314+
315+
3. Repeat step #1, dragging to above the window. The text and
316+
line numbers should gradually scroll up, with the selection
317+
updated continuously.
318+
319+
4. Repeat step #2, clicking a line number below the selection."""),
320320
}
321321

322-
_stack_viewer_spec = {
322+
_stackbrowser_spec = {
323323
'file': 'stackviewer',
324324
'kwds': {},
325325
'msg': "A stacktrace for a NameError exception.\n"
326-
"Expand 'idlelib ...' and '<locals>'.\n"
327-
"Check that exc_value, exc_tb, and exc_type are correct.\n"
326+
"Should have NameError and 1 traceback line."
328327
}
329328

330329
_tooltip_spec = {
@@ -438,5 +437,6 @@ def close(_=None):
438437
next_test()
439438
root.mainloop()
440439

440+
441441
if __name__ == '__main__':
442442
run()

Lib/idlelib/iomenu.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ def updaterecentfileslist(self,filename):
393393
if self.editwin.flist:
394394
self.editwin.update_recent_files_list(filename)
395395

396+
396397
def _io_binding(parent): # htest #
397398
from tkinter import Toplevel, Text
398399

@@ -430,6 +431,7 @@ def savecopy(self, event):
430431
editwin = MyEditWin(text)
431432
IOBinding(editwin)
432433

434+
433435
if __name__ == "__main__":
434436
from unittest import main
435437
main('idlelib.idle_test.test_iomenu', verbosity=2, exit=False)

Lib/idlelib/multicall.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ def handler(event):
442442
bindseq("<Enter>")
443443
bindseq("<Leave>")
444444

445+
445446
if __name__ == "__main__":
446447
from unittest import main
447448
main('idlelib.idle_test.test_mainmenu', verbosity=2, exit=False)

Lib/idlelib/outwin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ def setup(self):
182182
text.tag_raise('sel')
183183
self.write = self.owin.write
184184

185+
185186
if __name__ == '__main__':
186187
from unittest import main
187188
main('idlelib.idle_test.test_outwin', verbosity=2, exit=False)

Lib/idlelib/percolator.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ def delete(self, *args):
8686
print(self.name, ": delete", args)
8787
self.delegate.delete(*args)
8888

89-
box = tk.Toplevel(parent)
90-
box.title("Test Percolator")
89+
top = tk.Toplevel(parent)
90+
top.title("Test Percolator")
9191
x, y = map(int, parent.geometry().split('+')[1:])
92-
box.geometry("+%d+%d" % (x, y + 175))
93-
text = tk.Text(box)
92+
top.geometry("+%d+%d" % (x, y + 175))
93+
text = tk.Text(top)
9494
p = Percolator(text)
9595
pin = p.insertfilter
9696
pout = p.removefilter
@@ -103,13 +103,15 @@ def toggle2():
103103
(pin if var2.get() else pout)(t2)
104104

105105
text.pack()
106+
text.focus_set()
106107
var1 = tk.IntVar(parent)
107-
cb1 = tk.Checkbutton(box, text="Tracer1", command=toggle1, variable=var1)
108+
cb1 = tk.Checkbutton(top, text="Tracer1", command=toggle1, variable=var1)
108109
cb1.pack()
109110
var2 = tk.IntVar(parent)
110-
cb2 = tk.Checkbutton(box, text="Tracer2", command=toggle2, variable=var2)
111+
cb2 = tk.Checkbutton(top, text="Tracer2", command=toggle2, variable=var2)
111112
cb2.pack()
112113

114+
113115
if __name__ == "__main__":
114116
from unittest import main
115117
main('idlelib.idle_test.test_percolator', verbosity=2, exit=False)

Lib/idlelib/pyshell.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,6 +1694,7 @@ def main():
16941694
root.destroy()
16951695
capture_warnings(False)
16961696

1697+
16971698
if __name__ == "__main__":
16981699
main()
16991700

Lib/idlelib/redirector.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def my_insert(*args):
164164
original_insert(*args)
165165
original_insert = redir.register("insert", my_insert)
166166

167+
167168
if __name__ == "__main__":
168169
from unittest import main
169170
main('idlelib.idle_test.test_redirector', verbosity=2, exit=False)

Lib/idlelib/replace.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ def show_replace():
299299
button = Button(frame, text="Replace", command=show_replace)
300300
button.pack()
301301

302+
302303
if __name__ == '__main__':
303304
from unittest import main
304305
main('idlelib.idle_test.test_replace', verbosity=2, exit=False)

Lib/idlelib/scrolledlist.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def _scrolled_list(parent): # htest #
132132
top = Toplevel(parent)
133133
x, y = map(int, parent.geometry().split('+')[1:])
134134
top.geometry("+%d+%d" % (x+200, y + 175))
135+
135136
class MyScrolledList(ScrolledList):
136137
def fill_menu(self): self.menu.add_command(label="right click")
137138
def on_select(self, index): print("select", self.get(index))
@@ -141,9 +142,10 @@ def on_double(self, index): print("double", self.get(index))
141142
for i in range(30):
142143
scrolled_list.append("Item %02d" % i)
143144

145+
144146
if __name__ == '__main__':
145147
from unittest import main
146-
main('idlelib.idle_test.test_scrolledlist', verbosity=2,)
148+
main('idlelib.idle_test.test_scrolledlist', verbosity=2, exit=False)
147149

148150
from idlelib.idle_test.htest import run
149151
run(_scrolled_list)

Lib/idlelib/search.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ def show_find():
156156
button = Button(frame, text="Search (selection ignored)", command=show_find)
157157
button.pack()
158158

159+
159160
if __name__ == '__main__':
160161
from unittest import main
161162
main('idlelib.idle_test.test_search', verbosity=2, exit=False)

Lib/idlelib/sidebar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ def update_colors(self):
513513
self.change_callback()
514514

515515

516-
def _linenumbers_drag_scrolling(parent): # htest #
516+
def _sidebar_number_scrolling(parent): # htest #
517517
from idlelib.idle_test.test_sidebar import Dummy_editwin
518518

519519
top = tk.Toplevel(parent)
@@ -540,4 +540,4 @@ def _linenumbers_drag_scrolling(parent): # htest #
540540
main('idlelib.idle_test.test_sidebar', verbosity=2, exit=False)
541541

542542
from idlelib.idle_test.htest import run
543-
run(_linenumbers_drag_scrolling)
543+
run(_sidebar_number_scrolling)

Lib/idlelib/stackviewer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def setfunction(value, key=key, object=self.object):
113113
return sublist
114114

115115

116-
def _stack_viewer(parent): # htest #
116+
def _stackbrowser(parent): # htest #
117117
from idlelib.pyshell import PyShellFileList
118118
top = tk.Toplevel(parent)
119119
top.title("Test StackViewer")
@@ -131,4 +131,4 @@ def _stack_viewer(parent): # htest #
131131
main('idlelib.idle_test.test_stackviewer', verbosity=2, exit=False)
132132

133133
from idlelib.idle_test.htest import run
134-
run(_stack_viewer)
134+
run(_stackbrowser)

Lib/idlelib/statusbar.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def change():
4343
button.pack(side='bottom')
4444
frame.pack()
4545

46+
4647
if __name__ == '__main__':
4748
from unittest import main
4849
main('idlelib.idle_test.test_statusbar', verbosity=2, exit=False)

Lib/idlelib/tree.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ def _tree_widget(parent): # htest #
492492
node = TreeNode(sc.canvas, None, item)
493493
node.expand()
494494

495+
495496
if __name__ == '__main__':
496497
from unittest import main
497498
main('idlelib.idle_test.test_tree', verbosity=2, exit=False)

0 commit comments

Comments
 (0)
0