def test_val_or_dict(self): def func(opt, val=None): if val is None: return "test val" return (opt, val) options = {'test': None} self.assertEqual(ttk._val_or_dict(options, func), "test val") options = {'test': 3} self.assertEqual(ttk._val_or_dict(options, func), options)
def test_val_or_dict(self): def func(opt, val=None): if val is None: return "test val" return (opt, val) options = {"test": None} self.failUnlessEqual(ttk._val_or_dict(options, func), "test val") options = {"test": 3} self.failUnlessEqual(ttk._val_or_dict(options, func), options)
def test_val_or_dict(self): def func(res, opt=None, val=None): if opt is None: return res if val is None: return 'test val' return opt, val tk = MockTkApp() tk.call = func self.assertEqual(ttk._val_or_dict(tk, {}, '-test:3'), {'test': '3'}) self.assertEqual(ttk._val_or_dict(tk, {}, ('-test', 3)), {'test': 3}) self.assertEqual(ttk._val_or_dict(tk, {'test': None}, 'x:y'), 'test val') self.assertEqual(ttk._val_or_dict(tk, {'test': 3}, 'x:y'), {'test': 3})
def test_val_or_dict(self): def func(res, opt=None, val=None): if opt is None: return res if val is None: return "test val" return (opt, val) tk = MockTkApp() tk.call = func self.assertEqual(ttk._val_or_dict(tk, {}, '-test:3'), {'test': '3'}) self.assertEqual(ttk._val_or_dict(tk, {}, ('-test', 3)), {'test': 3}) self.assertEqual(ttk._val_or_dict(tk, {'test': None}, 'x:y'), 'test val') self.assertEqual(ttk._val_or_dict(tk, {'test': 3}, 'x:y'), {'test': 3})