예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
    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)
예제 #4
0
    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})
예제 #5
0
    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})