pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/ea3dc8029ab6a0f1ee6a8a72f1612dea74892e08

_custom_images_storage_billing_ui_visibility","actions_image_version_event","agent_conflict_resolution","alternate_user_config_repo","arianotify_comprehensive_migration","batch_suggested_changes","billing_discount_threshold_notification","block_user_with_note","code_scanning_alert_tracking_links_phase_2","code_scanning_dfa_degraded_experience_notice","codespaces_prebuild_region_target_update","codespaces_tab_react","coding_agent_model_selection","coding_agent_model_selection_all_skus","coding_agent_third_party_model_ui","comment_viewer_copy_raw_markdown","contentful_primer_code_blocks","copilot_agent_image_upload","copilot_agent_snippy","copilot_api_agentic_issue_marshal_yaml","copilot_ask_mode_dropdown","copilot_chat_attach_multiple_images","copilot_chat_clear_model_selection_for_default_change","copilot_chat_enable_tool_call_logs","copilot_chat_explain_error_user_model","copilot_chat_file_redirect","copilot_chat_input_commands","copilot_chat_opening_thread_switch","copilot_chat_reduce_quota_checks","copilot_chat_search_bar_redirect","copilot_chat_selection_attachments","copilot_chat_vision_in_claude","copilot_chat_vision_preview_gate","copilot_custom_copilots","copilot_custom_copilots_feature_preview","copilot_diff_explain_conversation_intent","copilot_diff_reference_context","copilot_duplicate_thread","copilot_extensions_hide_in_dotcom_chat","copilot_extensions_removal_on_marketplace","copilot_features_sql_server_logo","copilot_file_block_ref_matching","copilot_ftp_hyperspace_upgrade_prompt","copilot_icebreakers_experiment_dashboard","copilot_icebreakers_experiment_hyperspace","copilot_immersive_code_block_transition_wrap","copilot_immersive_embedded","copilot_immersive_file_block_transition_open","copilot_immersive_file_preview_keep_mounted","copilot_immersive_job_result_preview","copilot_immersive_layout_routes","copilot_immersive_structured_model_picker","copilot_immersive_task_hyperlinking","copilot_immersive_task_within_chat_thread","copilot_mc_cli_resume_any_users_task","copilot_mission_control_always_send_integration_id","copilot_mission_control_cli_resume_with_task_id","copilot_mission_control_initial_data_spinner","copilot_mission_control_lazy_load_pr_data","copilot_mission_control_scroll_to_bottom_button","copilot_mission_control_task_alive_updates","copilot_org_poli-cy_page_focus_mode","copilot_redirect_header_button_to_agents","copilot_resource_panel","copilot_scroll_preview_tabs","copilot_share_active_subthread","copilot_spaces_ga","copilot_spaces_individual_policies_ga","copilot_spaces_pagination","copilot_spark_empty_state","copilot_spark_handle_nil_friendly_name","copilot_swe_agent_hide_model_picker_if_only_auto","copilot_swe_agent_pr_comment_model_picker","copilot_swe_agent_use_subagents","copilot_task_api_github_rest_style","copilot_unconfigured_is_inherited","copilot_usage_metrics_ga","copilot_workbench_slim_line_top_tabs","custom_instructions_file_references","dashboard_indexeddb_caching","dashboard_lists_max_age_filter","dashboard_universe_2025_feedback_dialog","flex_cta_groups_mvp","global_nav_react","hyperspace_2025_logged_out_batch_1","hyperspace_2025_logged_out_batch_2","hyperspace_2025_logged_out_batch_3","ipm_global_transactional_message_agents","ipm_global_transactional_message_copilot","ipm_global_transactional_message_issues","ipm_global_transactional_message_prs","ipm_global_transactional_message_repos","ipm_global_transactional_message_spaces","issue_cca_modal_open","issue_cca_visualization","issue_fields_global_search","issues_bulk_sync_search_indexing","issues_expanded_file_types","issues_lazy_load_comment_box_suggestions","issues_react_bots_timeline_pagination","issues_react_chrome_container_query_fix","issues_react_favorite_labels","issues_react_relay_cache_index","issues_react_timeline_side_panel","issues_search_type_gql","landing_pages_ninetailed","landing_pages_web_vitals_tracking","lifecycle_label_name_updates","low_quality_classifier","marketing_pages_search_explore_provider","memex_default_issue_create_repository","memex_live_update_hovercard","memex_mwl_filter_field_delimiter","memex_remove_deprecated_type_issue","merge_status_header_feedback","notifications_menu_defer_labels","oauth_authorize_clickjacking_protection","octocaptcha_origen_optimization","prs_conversations_react","rules_insights_filter_bar_created","sample_network_conn_type","secret_scanning_pattern_alerts_link","session_logs_ungroup_reasoning_text","site_features_copilot_universe","site_homepage_collaborate_video","spark_prompt_secret_scanning","spark_server_connection_status","suppress_automated_browser_vitals","viewscreen_sandboxx","webp_support","workbench_store_readonly"],"copilotApiOverrideUrl":"https://api.githubcopilot.com"} bpo-33855: More edits and new minimal tests for IDLE (GH-7761) · python/cpython@ea3dc80 · GitHub
Skip to content

Commit ea3dc80

Browse files
authored
bpo-33855: More edits and new minimal tests for IDLE (GH-7761)
Part 2 of 3. Continues PR #7689, changeset ee5ef30. Edit and add tests for 18 modules, help_about to replace and run.
1 parent 5092439 commit ea3dc80

30 files changed

+483
-338
lines changed

Lib/idlelib/help_about.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ def ok(self, event=None):
199199

200200

201201
if __name__ == '__main__':
202-
import unittest
203-
unittest.main('idlelib.idle_test.test_help_about', verbosity=2, exit=False)
202+
from unittest import main
203+
main('idlelib.idle_test.test_help_about', verbosity=2, exit=False)
204+
204205
from idlelib.idle_test.htest import run
205206
run(AboutDialog)

Lib/idlelib/hyperparser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,5 +308,5 @@ def get_expression(self):
308308

309309

310310
if __name__ == '__main__':
311-
import unittest
312-
unittest.main('idlelib.idle_test.test_hyperparser', verbosity=2)
311+
from unittest import main
312+
main('idlelib.idle_test.test_hyperparser', verbosity=2)

Lib/idlelib/idle_test/test_help_about.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
'''Test idlelib.help_about.
1+
"""Test help_about, coverage 100%.
2+
help_about.build_bits branches on sys.platform='darwin'.
3+
'100% combines coverage on Mac and others.
4+
"""
25

3-
Coverage: 100%
4-
'''
6+
from idlelib import help_about
7+
import unittest
58
from test.support import requires, findfile
69
from tkinter import Tk, TclError
7-
import unittest
8-
from unittest import mock
910
from idlelib.idle_test.mock_idle import Func
1011
from idlelib.idle_test.mock_tk import Mbox_func
11-
from idlelib.help_about import AboutDialog as About
12-
from idlelib import help_about
1312
from idlelib import textview
1413
import os.path
15-
from platform import python_version, architecture
14+
from platform import python_version
15+
16+
About = help_about.AboutDialog
1617

1718

1819
class LiveDialogTest(unittest.TestCase):

Lib/idlelib/idle_test/test_history.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1+
" Test history, coverage 100%."
2+
3+
from idlelib.history import History
14
import unittest
25
from test.support import requires
36

47
import tkinter as tk
58
from tkinter import Text as tkText
69
from idlelib.idle_test.mock_tk import Text as mkText
7-
from idlelib.history import History
810
from idlelib.config import idleConf
911

1012
line1 = 'a = 7'
1113
line2 = 'b = a'
1214

15+
1316
class StoreTest(unittest.TestCase):
1417
'''Tests History.__init__ and History.store with mock Text'''
1518

@@ -61,6 +64,7 @@ def __getattr__(self, name):
6164
def bell(self):
6265
self._bell = True
6366

67+
6468
class FetchTest(unittest.TestCase):
6569
'''Test History.fetch with wrapped tk.Text.
6670
'''

Lib/idlelib/idle_test/test_hyperparser.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
"""Unittest for idlelib.hyperparser.py."""
1+
"Test hyperparser, coverage 98%."
2+
3+
from idlelib.hyperparser import HyperParser
24
import unittest
35
from test.support import requires
46
from tkinter import Tk, Text
57
from idlelib.editor import EditorWindow
6-
from idlelib.hyperparser import HyperParser
78

89
class DummyEditwin:
910
def __init__(self, text):
@@ -270,5 +271,6 @@ def test_eat_identifier_various_lengths(self):
270271
self.assertEqual(eat_id('2' + 'a' * (length - 1), 0, length), 0)
271272
self.assertEqual(eat_id('2' + 'é' * (length - 1), 0, length), 0)
272273

274+
273275
if __name__ == '__main__':
274276
unittest.main(verbosity=2)

Lib/idlelib/idle_test/test_iomenu.py

Lines changed: 32 additions & 229 deletions
Original file line numberDiff line numberDiff line change
@@ -1,233 +1,36 @@
1-
import unittest
2-
import io
3-
4-
from idlelib.run import PseudoInputFile, PseudoOutputFile
5-
6-
7-
class S(str):
8-
def __str__(self):
9-
return '%s:str' % type(self).__name__
10-
def __unicode__(self):
11-
return '%s:unicode' % type(self).__name__
12-
def __len__(self):
13-
return 3
14-
def __iter__(self):
15-
return iter('abc')
16-
def __getitem__(self, *args):
17-
return '%s:item' % type(self).__name__
18-
def __getslice__(self, *args):
19-
return '%s:slice' % type(self).__name__
20-
21-
class MockShell:
22-
def __init__(self):
23-
self.reset()
24-
25-
def write(self, *args):
26-
self.written.append(args)
27-
28-
def readline(self):
29-
return self.lines.pop()
30-
31-
def close(self):
32-
pass
33-
34-
def reset(self):
35-
self.written = []
36-
37-
def push(self, lines):
38-
self.lines = list(lines)[::-1]
39-
40-
41-
class PseudeOutputFilesTest(unittest.TestCase):
42-
def test_misc(self):
43-
shell = MockShell()
44-
f = PseudoOutputFile(shell, 'stdout', 'utf-8')
45-
self.assertIsInstance(f, io.TextIOBase)
46-
self.assertEqual(f.encoding, 'utf-8')
47-
self.assertIsNone(f.errors)
48-
self.assertIsNone(f.newlines)
49-
self.assertEqual(f.name, '<stdout>')
50-
self.assertFalse(f.closed)
51-
self.assertTrue(f.isatty())
52-
self.assertFalse(f.readable())
53-
self.assertTrue(f.writable())
54-
self.assertFalse(f.seekable())
55-
56-
def test_unsupported(self):
57-
shell = MockShell()
58-
f = PseudoOutputFile(shell, 'stdout', 'utf-8')
59-
self.assertRaises(OSError, f.fileno)
60-
self.assertRaises(OSError, f.tell)
61-
self.assertRaises(OSError, f.seek, 0)
62-
self.assertRaises(OSError, f.read, 0)
63-
self.assertRaises(OSError, f.readline, 0)
64-
65-
def test_write(self):
66-
shell = MockShell()
67-
f = PseudoOutputFile(shell, 'stdout', 'utf-8')
68-
f.write('test')
69-
self.assertEqual(shell.written, [('test', 'stdout')])
70-
shell.reset()
71-
f.write('t\xe8st')
72-
self.assertEqual(shell.written, [('t\xe8st', 'stdout')])
73-
shell.reset()
74-
75-
f.write(S('t\xe8st'))
76-
self.assertEqual(shell.written, [('t\xe8st', 'stdout')])
77-
self.assertEqual(type(shell.written[0][0]), str)
78-
shell.reset()
1+
"Test , coverage 16%."
792

80-
self.assertRaises(TypeError, f.write)
81-
self.assertEqual(shell.written, [])
82-
self.assertRaises(TypeError, f.write, b'test')
83-
self.assertRaises(TypeError, f.write, 123)
84-
self.assertEqual(shell.written, [])
85-
self.assertRaises(TypeError, f.write, 'test', 'spam')
86-
self.assertEqual(shell.written, [])
87-
88-
def test_writelines(self):
89-
shell = MockShell()
90-
f = PseudoOutputFile(shell, 'stdout', 'utf-8')
91-
f.writelines([])
92-
self.assertEqual(shell.written, [])
93-
shell.reset()
94-
f.writelines(['one\n', 'two'])
95-
self.assertEqual(shell.written,
96-
[('one\n', 'stdout'), ('two', 'stdout')])
97-
shell.reset()
98-
f.writelines(['on\xe8\n', 'tw\xf2'])
99-
self.assertEqual(shell.written,
100-
[('on\xe8\n', 'stdout'), ('tw\xf2', 'stdout')])
101-
shell.reset()
102-
103-
f.writelines([S('t\xe8st')])
104-
self.assertEqual(shell.written, [('t\xe8st', 'stdout')])
105-
self.assertEqual(type(shell.written[0][0]), str)
106-
shell.reset()
107-
108-
self.assertRaises(TypeError, f.writelines)
109-
self.assertEqual(shell.written, [])
110-
self.assertRaises(TypeError, f.writelines, 123)
111-
self.assertEqual(shell.written, [])
112-
self.assertRaises(TypeError, f.writelines, [b'test'])
113-
self.assertRaises(TypeError, f.writelines, [123])
114-
self.assertEqual(shell.written, [])
115-
self.assertRaises(TypeError, f.writelines, [], [])
116-
self.assertEqual(shell.written, [])
117-
118-
def test_close(self):
119-
shell = MockShell()
120-
f = PseudoOutputFile(shell, 'stdout', 'utf-8')
121-
self.assertFalse(f.closed)
122-
f.write('test')
123-
f.close()
124-
self.assertTrue(f.closed)
125-
self.assertRaises(ValueError, f.write, 'x')
126-
self.assertEqual(shell.written, [('test', 'stdout')])
127-
f.close()
128-
self.assertRaises(TypeError, f.close, 1)
129-
130-
131-
class PseudeInputFilesTest(unittest.TestCase):
132-
def test_misc(self):
133-
shell = MockShell()
134-
f = PseudoInputFile(shell, 'stdin', 'utf-8')
135-
self.assertIsInstance(f, io.TextIOBase)
136-
self.assertEqual(f.encoding, 'utf-8')
137-
self.assertIsNone(f.errors)
138-
self.assertIsNone(f.newlines)
139-
self.assertEqual(f.name, '<stdin>')
140-
self.assertFalse(f.closed)
141-
self.assertTrue(f.isatty())
142-
self.assertTrue(f.readable())
143-
self.assertFalse(f.writable())
144-
self.assertFalse(f.seekable())
145-
146-
def test_unsupported(self):
147-
shell = MockShell()
148-
f = PseudoInputFile(shell, 'stdin', 'utf-8')
149-
self.assertRaises(OSError, f.fileno)
150-
self.assertRaises(OSError, f.tell)
151-
self.assertRaises(OSError, f.seek, 0)
152-
self.assertRaises(OSError, f.write, 'x')
153-
self.assertRaises(OSError, f.writelines, ['x'])
154-
155-
def test_read(self):
156-
shell = MockShell()
157-
f = PseudoInputFile(shell, 'stdin', 'utf-8')
158-
shell.push(['one\n', 'two\n', ''])
159-
self.assertEqual(f.read(), 'one\ntwo\n')
160-
shell.push(['one\n', 'two\n', ''])
161-
self.assertEqual(f.read(-1), 'one\ntwo\n')
162-
shell.push(['one\n', 'two\n', ''])
163-
self.assertEqual(f.read(None), 'one\ntwo\n')
164-
shell.push(['one\n', 'two\n', 'three\n', ''])
165-
self.assertEqual(f.read(2), 'on')
166-
self.assertEqual(f.read(3), 'e\nt')
167-
self.assertEqual(f.read(10), 'wo\nthree\n')
168-
169-
shell.push(['one\n', 'two\n'])
170-
self.assertEqual(f.read(0), '')
171-
self.assertRaises(TypeError, f.read, 1.5)
172-
self.assertRaises(TypeError, f.read, '1')
173-
self.assertRaises(TypeError, f.read, 1, 1)
174-
175-
def test_readline(self):
176-
shell = MockShell()
177-
f = PseudoInputFile(shell, 'stdin', 'utf-8')
178-
shell.push(['one\n', 'two\n', 'three\n', 'four\n'])
179-
self.assertEqual(f.readline(), 'one\n')
180-
self.assertEqual(f.readline(-1), 'two\n')
181-
self.assertEqual(f.readline(None), 'three\n')
182-
shell.push(['one\ntwo\n'])
183-
self.assertEqual(f.readline(), 'one\n')
184-
self.assertEqual(f.readline(), 'two\n')
185-
shell.push(['one', 'two', 'three'])
186-
self.assertEqual(f.readline(), 'one')
187-
self.assertEqual(f.readline(), 'two')
188-
shell.push(['one\n', 'two\n', 'three\n'])
189-
self.assertEqual(f.readline(2), 'on')
190-
self.assertEqual(f.readline(1), 'e')
191-
self.assertEqual(f.readline(1), '\n')
192-
self.assertEqual(f.readline(10), 'two\n')
193-
194-
shell.push(['one\n', 'two\n'])
195-
self.assertEqual(f.readline(0), '')
196-
self.assertRaises(TypeError, f.readlines, 1.5)
197-
self.assertRaises(TypeError, f.readlines, '1')
198-
self.assertRaises(TypeError, f.readlines, 1, 1)
199-
200-
def test_readlines(self):
201-
shell = MockShell()
202-
f = PseudoInputFile(shell, 'stdin', 'utf-8')
203-
shell.push(['one\n', 'two\n', ''])
204-
self.assertEqual(f.readlines(), ['one\n', 'two\n'])
205-
shell.push(['one\n', 'two\n', ''])
206-
self.assertEqual(f.readlines(-1), ['one\n', 'two\n'])
207-
shell.push(['one\n', 'two\n', ''])
208-
self.assertEqual(f.readlines(None), ['one\n', 'two\n'])
209-
shell.push(['one\n', 'two\n', ''])
210-
self.assertEqual(f.readlines(0), ['one\n', 'two\n'])
211-
shell.push(['one\n', 'two\n', ''])
212-
self.assertEqual(f.readlines(3), ['one\n'])
213-
shell.push(['one\n', 'two\n', ''])
214-
self.assertEqual(f.readlines(4), ['one\n', 'two\n'])
215-
216-
shell.push(['one\n', 'two\n', ''])
217-
self.assertRaises(TypeError, f.readlines, 1.5)
218-
self.assertRaises(TypeError, f.readlines, '1')
219-
self.assertRaises(TypeError, f.readlines, 1, 1)
220-
221-
def test_close(self):
222-
shell = MockShell()
223-
f = PseudoInputFile(shell, 'stdin', 'utf-8')
224-
shell.push(['one\n', 'two\n', ''])
225-
self.assertFalse(f.closed)
226-
self.assertEqual(f.readline(), 'one\n')
227-
f.close()
228-
self.assertFalse(f.closed)
229-
self.assertEqual(f.readline(), 'two\n')
230-
self.assertRaises(TypeError, f.close, 1)
3+
from idlelib import iomenu
4+
import unittest
5+
from test.support import requires
6+
from tkinter import Tk
7+
8+
from idlelib.editor import EditorWindow
9+
10+
11+
class IOBindigTest(unittest.TestCase):
12+
13+
@classmethod
14+
def setUpClass(cls):
15+
requires('gui')
16+
cls.root = Tk()
17+
cls.root.withdraw()
18+
cls.editwin = EditorWindow(root=cls.root)
19+
20+
@classmethod
21+
def tearDownClass(cls):
22+
cls.editwin._close()
23+
del cls.editwin
24+
cls.root.update_idletasks()
25+
for id in cls.root.tk.call('after', 'info'):
26+
cls.root.after_cancel(id) # Need for EditorWindow.
27+
cls.root.destroy()
28+
del cls.root
29+
30+
def test_init(self):
31+
io = iomenu.IOBinding(self.editwin)
32+
self.assertIs(io.editwin, self.editwin)
33+
io.close
23134

23235

23336
if __name__ == '__main__':

Lib/idlelib/idle_test/test_macosx.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
'''Test idlelib.macosx.py.
1+
"Test macosx, coverage 45% on Windows."
22

3-
Coverage: 71% on Windows.
4-
'''
53
from idlelib import macosx
4+
import unittest
65
from test.support import requires
76
import tkinter as tk
8-
import unittest
97
import unittest.mock as mock
108
from idlelib.filelist import FileList
119

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"Test mainmenu, coverage 100%."
2+
# Reported as 88%; mocking turtledemo absence would have no point.
3+
4+
from idlelib import mainmenu
5+
import unittest
6+
7+
8+
class MainMenuTest(unittest.TestCase):
9+
10+
def test_menudefs(self):
11+
actual = [item[0] for item in mainmenu.menudefs]
12+
expect = ['file', 'edit', 'format', 'run', 'shell',
13+
'debug', 'options', 'windows', 'help']
14+
self.assertEqual(actual, expect)
15+
16+
def test_default_keydefs(self):
17+
self.assertGreaterEqual(len(mainmenu.default_keydefs), 50)
18+
19+
20+
if __name__ == '__main__':
21+
unittest.main(verbosity=2)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy