def setUp(self): self.model = Settable(attr=0) proxy = Proxy(FakeView(), self.model) self.combo = disabledeprecationcall(self.type) self.combo.data_type = int self.combo.model_attribute = 'attr' self.combo.prefill([('foo', 0), ('bar', 1)]) proxy.add_widget('attr', self.combo) self.combo.show()
def test_prefill_attr_none(self): model = Settable(attr=None) proxy = Proxy(FakeView(), model) combo = ProxyComboEntry() combo.data_type = int combo.model_attribute = 'attr' combo.prefill([('foo', 10), ('bar', 20)]) proxy.add_widget('attr', combo) self.assertEqual(model.attr, None)
def test_prefill_attr_none(self): model = Settable(attr=None) proxy = Proxy(FakeView(), model) combo = ProxyComboBox() combo.data_type = int combo.model_attribute = 'attr' combo.prefill([('foo', 10), ('bar', 20)]) proxy.add_widget('attr', combo) # Even though attr is None, the combo doesn't allow something # not prefilled in it to be selected. In this case, it will select # the first item (prefill actually does that) instead. self.assertEqual(model.attr, 10)