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

Method test_set

Lib/test/test_ttk/test_widgets.py:888–922  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

886 self.assertRaises(tkinter.TclError, self.scale.get, 0, '')
887
888 def test_set(self):
889 if self.wantobjects:
890 conv = lambda x: x
891 else:
892 conv = float
893
894 # set restricts the max/min values according to the current range
895 max = conv(self.scale['to'])
896 new_max = max + 10
897 self.scale.set(new_max)
898 self.assertEqual(conv(self.scale.get()), max)
899 min = conv(self.scale['from'])
900 self.scale.set(min - 1)
901 self.assertEqual(conv(self.scale.get()), min)
902
903 # changing directly the variable doesn't impose this limitation tho
904 var = tkinter.DoubleVar(self.root)
905 self.scale['variable'] = var
906 var.set(max + 5)
907 self.assertEqual(conv(self.scale.get()), var.get())
908 self.assertEqual(conv(self.scale.get()), max + 5)
909 del var
910 gc_collect() # For PyPy or other GCs.
911
912 # the same happens with the value option
913 self.scale['value'] = max + 10
914 self.assertEqual(conv(self.scale.get()), max + 10)
915 self.assertEqual(conv(self.scale.get()), conv(self.scale['value']))
916
917 # nevertheless, note that the max/min values we can get specifying
918 # x, y coords are the ones according to the current range
919 self.assertEqual(conv(self.scale.get(0, 0)), min)
920 self.assertEqual(conv(self.scale.get(self.scale.winfo_width(), 0)), max)
921
922 self.assertRaises(tkinter.TclError, self.scale.set, None)
923
924
925@add_configure_tests(StandardTtkOptionsTests)

Callers

nothing calls this directly

Calls 8

getMethod · 0.95
gc_collectFunction · 0.90
convFunction · 0.85
winfo_widthMethod · 0.80
setMethod · 0.45
assertEqualMethod · 0.45
getMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected