def test_list_from_layouttuple(self):
        # empty layout tuple
        self.assertFalse(ttk._list_from_layouttuple(()))

        # shortest layout tuple
        self.assertEqual(ttk._list_from_layouttuple(('name', )),
                         [('name', {})])

        # not so interesting ltuple
        sample_ltuple = ('name', '-option', 'value')
        self.assertEqual(ttk._list_from_layouttuple(sample_ltuple),
                         [('name', {
                             'option': 'value'
                         })])

        # empty children
        self.assertEqual(
            ttk._list_from_layouttuple(('something', '-children', ())),
            [('something', {
                'children': []
            })])

        # more interesting ltuple
        ltuple = ('name', '-option', 'niceone', '-children',
                  (('otherone', '-children', (('child', )), '-otheropt',
                    'othervalue')))
        self.assertEqual(ttk._list_from_layouttuple(ltuple), [('name', {
            'option':
            'niceone',
            'children': [('otherone', {
                'otheropt': 'othervalue',
                'children': [('child', {})]
            })]
        })])

        # bad tuples
        self.assertRaises(ValueError, ttk._list_from_layouttuple,
                          ('name', 'no_minus'))
        self.assertRaises(ValueError, ttk._list_from_layouttuple,
                          ('name', 'no_minus', 'value'))
        self.assertRaises(ValueError, ttk._list_from_layouttuple,
                          ('something', '-children'))  # no children
        import tkinter
        if not tkinter._default_root or tkinter._default_root.wantobjects():
            self.assertRaises(
                ValueError, ttk._list_from_layouttuple,
                ('something', '-children', 'value'))  # invalid children
Ejemplo n.º 2
0
    def test_list_from_layouttuple(self):
        # empty layout tuple
        self.assertFalse(ttk._list_from_layouttuple(()))

        # shortest layout tuple
        self.assertEqual(ttk._list_from_layouttuple(('name', )),
            [('name', {})])

        # not so interesting ltuple
        sample_ltuple = ('name', '-option', 'value')
        self.assertEqual(ttk._list_from_layouttuple(sample_ltuple),
            [('name', {'option': 'value'})])

        # empty children
        self.assertEqual(ttk._list_from_layouttuple(
            ('something', '-children', ())),
            [('something', {'children': []})]
        )

        # more interesting ltuple
        ltuple = (
            'name', '-option', 'niceone', '-children', (
                ('otherone', '-children', (
                    ('child', )), '-otheropt', 'othervalue'
                )
            )
        )
        self.assertEqual(ttk._list_from_layouttuple(ltuple),
            [('name', {'option': 'niceone', 'children':
                [('otherone', {'otheropt': 'othervalue', 'children':
                    [('child', {})]
                })]
            })]
        )

        # bad tuples
        self.assertRaises(ValueError, ttk._list_from_layouttuple,
            ('name', 'no_minus'))
        self.assertRaises(ValueError, ttk._list_from_layouttuple,
            ('name', 'no_minus', 'value'))
        self.assertRaises(ValueError, ttk._list_from_layouttuple,
            ('something', '-children')) # no children
        import tkinter
        if not tkinter._default_root or tkinter._default_root.wantobjects():
            self.assertRaises(ValueError, ttk._list_from_layouttuple,
                ('something', '-children', 'value')) # invalid children
Ejemplo n.º 3
0
    def test_list_from_layouttuple(self):
        tk = MockTkApp()

        # empty layout tuple
        self.assertFalse(ttk._list_from_layouttuple(tk, ()))

        # shortest layout tuple
        self.assertEqual(ttk._list_from_layouttuple(tk, ('name', )),
            [('name', {})])

        # not so interesting ltuple
        sample_ltuple = ('name', '-option', 'value')
        self.assertEqual(ttk._list_from_layouttuple(tk, sample_ltuple),
            [('name', {'option': 'value'})])

        # empty children
        self.assertEqual(ttk._list_from_layouttuple(tk,
            ('something', '-children', ())),
            [('something', {'children': []})]
        )

        # more interesting ltuple
        ltuple = (
            'name', '-option', 'niceone', '-children', (
                ('otherone', '-children', (
                    ('child', )), '-otheropt', 'othervalue'
                )
            )
        )
        self.assertEqual(ttk._list_from_layouttuple(tk, ltuple),
            [('name', {'option': 'niceone', 'children':
                [('otherone', {'otheropt': 'othervalue', 'children':
                    [('child', {})]
                })]
            })]
        )

        # bad tuples
        self.assertRaises(ValueError, ttk._list_from_layouttuple, tk,
            ('name', 'no_minus'))
        self.assertRaises(ValueError, ttk._list_from_layouttuple, tk,
            ('name', 'no_minus', 'value'))
        self.assertRaises(ValueError, ttk._list_from_layouttuple, tk,
            ('something', '-children')) # no children
Ejemplo n.º 4
0
    def test_list_from_layouttuple(self):
        tk = MockTkApp()

        # empty layout tuple
        self.assertFalse(ttk._list_from_layouttuple(tk, ()))

        # shortest layout tuple
        self.assertEqual(ttk._list_from_layouttuple(tk, ('name', )),
            [('name', {})])

        # not so interesting ltuple
        sample_ltuple = ('name', '-option', 'value')
        self.assertEqual(ttk._list_from_layouttuple(tk, sample_ltuple),
            [('name', {'option': 'value'})])

        # empty children
        self.assertEqual(ttk._list_from_layouttuple(tk,
            ('something', '-children', ())),
            [('something', {'children': []})]
        )

        # more interesting ltuple
        ltuple = (
            'name', '-option', 'niceone', '-children', (
                ('otherone', '-children', (
                    ('child', )), '-otheropt', 'othervalue'
                )
            )
        )
        self.assertEqual(ttk._list_from_layouttuple(tk, ltuple),
            [('name', {'option': 'niceone', 'children':
                [('otherone', {'otheropt': 'othervalue', 'children':
                    [('child', {})]
                })]
            })]
        )

        # bad tuples
        self.assertRaises(ValueError, ttk._list_from_layouttuple, tk,
            ('name', 'no_minus'))
        self.assertRaises(ValueError, ttk._list_from_layouttuple, tk,
            ('name', 'no_minus', 'value'))
        self.assertRaises(ValueError, ttk._list_from_layouttuple, tk,
            ('something', '-children')) # no children
Ejemplo n.º 5
0
    def test_list_from_layouttuple(self):
        # empty layout tuple
        self.failIf(ttk._list_from_layouttuple(()))

        # shortest layout tuple
        self.failUnlessEqual(ttk._list_from_layouttuple(("name",)), [("name", {})])

        # not so interesting ltuple
        sample_ltuple = ("name", "-option", "value")
        self.failUnlessEqual(ttk._list_from_layouttuple(sample_ltuple), [("name", {"option": "value"})])

        # empty children
        self.failUnlessEqual(
            ttk._list_from_layouttuple(("something", "-children", ())), [("something", {"children": []})]
        )

        # more interesting ltuple
        ltuple = (
            "name",
            "-option",
            "niceone",
            "-children",
            (("otherone", "-children", (("child",)), "-otheropt", "othervalue")),
        )
        self.failUnlessEqual(
            ttk._list_from_layouttuple(ltuple),
            [
                (
                    "name",
                    {
                        "option": "niceone",
                        "children": [("otherone", {"otheropt": "othervalue", "children": [("child", {})]})],
                    },
                )
            ],
        )

        # bad tuples
        self.failUnlessRaises(ValueError, ttk._list_from_layouttuple, ("name", "no_minus"))
        self.failUnlessRaises(ValueError, ttk._list_from_layouttuple, ("name", "no_minus", "value"))
        self.failUnlessRaises(ValueError, ttk._list_from_layouttuple, ("something", "-children"))  # no children
        self.failUnlessRaises(
            ValueError, ttk._list_from_layouttuple, ("something", "-children", "value")
        )  # invalid children