MCPcopy Index your code
hub / github.com/python/cpython / test_variable_change

Method test_variable_change

Lib/test/test_ttk/test_extensions.py:134–173  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

132
133
134 def test_variable_change(self):
135 x = ttk.LabeledScale(self.root)
136 x.pack()
137 x.update()
138
139 curr_xcoord = x.scale.coords()[0]
140 newval = x.value + 1
141 x.value = newval
142 # The following update is needed since the test doesn't use mainloop,
143 # at the same time this shouldn't affect test outcome
144 x.update()
145 self.assertEqual(x.value, newval)
146 self.assertEqual(x.label['text'],
147 newval if self.wantobjects else str(newval))
148 self.assertEqual(float(x.scale.get()), newval)
149 self.assertGreater(x.scale.coords()[0], curr_xcoord)
150 self.assertEqual(x.scale.coords()[0],
151 int(x.label.place_info()['x']))
152
153 # value outside range
154 if self.wantobjects:
155 conv = lambda x: x
156 else:
157 conv = int
158 x.value = conv(x.scale['to']) + 1 # no changes shouldn't happen
159 x.update()
160 self.assertEqual(x.value, newval)
161 self.assertEqual(conv(x.label['text']), newval)
162 self.assertEqual(float(x.scale.get()), newval)
163 self.assertEqual(x.scale.coords()[0],
164 int(x.label.place_info()['x']))
165
166 # non-integer value
167 x.value = newval = newval + 1.5
168 x.update()
169 self.assertEqual(x.value, int(newval))
170 self.assertEqual(conv(x.label['text']), int(newval))
171 self.assertEqual(float(x.scale.get()), newval)
172
173 x.destroy()
174
175
176 def test_resize(self):

Callers

nothing calls this directly

Calls 10

destroyMethod · 0.95
strFunction · 0.85
convFunction · 0.85
assertGreaterMethod · 0.80
place_infoMethod · 0.80
packMethod · 0.45
updateMethod · 0.45
coordsMethod · 0.45
assertEqualMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected