Skip to content

Commit c4cf031

Browse files
committed
Test bold_toggle with set_samples.
1 parent 307c641 commit c4cf031

File tree

2 files changed

+32
-18
lines changed

2 files changed

+32
-18
lines changed

‎Lib/idlelib/configdialog.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,14 @@ def create_action_buttons(self):
153153
def create_page_font_tab(self):
154154
"""Return frame of widgets for Font/Tabs tab.
155155
156+
Enable users to provisionally change font face, size, or
157+
boldness and to see the consequence of proposed choices. Each
158+
action set 3 options in changes structuree and changes the
159+
corresponding aspect of the font sample on this page and
160+
highlight sample on highlight page.
161+
162+
Enable users to change spaces entered for indent tabs.
163+
156164
Tk Variables:
157165
font_name: Font face.
158166
font_size: Font size.
@@ -161,7 +169,7 @@ def create_page_font_tab(self):
161169
space_num: Indentation width.
162170
163171
Data Attribute:
164-
edit_font: Font widget with default font name, size, and weight.
172+
edit_font: Font with default font name, size, and weight.
165173
166174
Methods:
167175
load_font_cfg: Set vars and fontlist.

‎Lib/idlelib/idle_test/test_configdialog.py‎

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,16 @@ def tearDownModule():
4646

4747

4848
class FontTabTest(unittest.TestCase):
49+
"Test that font widget enable users to make font changes."
50+
4951

5052
def setUp(self):
5153
changes.clear()
5254

5355
def test_font_set(self):
54-
# Set values guaranteed not to be defaults.
56+
# Test that setting a font Variable results in 3 provisional
57+
# change entries. Use values sure to not be defaults.
58+
# Other font tests verify that user actions set Variables.
5559
default_font = idleConf.GetFont(root, 'main', 'EditorWindow')
5660
default_size = str(default_font[1])
5761
default_bold = default_font[2] == 'bold'
@@ -73,27 +77,29 @@ def test_font_set(self):
7377
'font-bold': str(not default_bold)}}
7478
self.assertEqual(mainpage, expected)
7579

76-
def test_bold_toggle(self):
77-
bt = dialog.bold_toggle
78-
mock_bold = bt['variable'] = BooleanVar(root)
79-
mock_command = bt['command'] = Func()
80-
bt.invoke()
81-
self.assertEqual(mock_command.called, 1)
82-
self.assertEqual(bt['onvalue'], mock_bold.get())
83-
bt.invoke()
84-
self.assertEqual(mock_command.called, 2)
85-
self.assertEqual(bt['offvalue'], mock_bold.get())
86-
del mock_command, mock_bold
87-
88-
def test_set_samples(self):
80+
def test_set_samples_bold_toggle(self):
81+
# Set up.
8982
d = dialog
90-
d.font_sample, d.highlight_sample = {}, {}
83+
d.font_sample, d.highlight_sample = {}, {} # Must undo this.
9184
d.font_name.set('test')
9285
d.font_size.set('5')
9386
d.font_bold.set(1)
87+
expected0 = {'font': ('test', '5', 'normal')}
88+
expected1 = {'font': ('test', '5', 'bold')}
89+
90+
# Test set_samples.
9491
d.set_samples()
95-
expected = {'font': ('test', '5', 'bold')}
96-
self.assertTrue(d.font_sample == d.highlight_sample == expected)
92+
self.assertTrue(d.font_sample == d.highlight_sample == expected1)
93+
94+
# Test bold_toggle.
95+
d.bold_toggle.invoke()
96+
self.assertFalse(d.font_bold.get())
97+
self.assertTrue(d.font_sample == d.highlight_sample == expected0)
98+
d.bold_toggle.invoke()
99+
self.assertTrue(d.font_bold.get())
100+
self.assertTrue(d.font_sample == d.highlight_sample == expected1)
101+
102+
# Clean up.
97103
del d.font_sample, d.highlight_sample
98104

99105
def test_tabspace(self):

0 commit comments

Comments
 (0)