示例#1
0
    def test_dict_from_tcltuple(self):
        fakettuple = ('-a', '{1 2 3}', '-something', 'foo')

        self.assertEqual(ttk._dict_from_tcltuple(fakettuple, False), {
            '-a': '{1 2 3}',
            '-something': 'foo'
        })

        self.assertEqual(ttk._dict_from_tcltuple(fakettuple), {
            'a': '{1 2 3}',
            'something': 'foo'
        })

        # passing a tuple with a single item should return an empty dict,
        # since it tries to break the tuple by pairs.
        self.assertFalse(ttk._dict_from_tcltuple(('single', )))

        sspec = MockStateSpec('a', 'b')
        self.assertEqual(ttk._dict_from_tcltuple(('-a', (sspec, 'val'))),
                         {'a': [('a', 'b', 'val')]})

        self.assertEqual(
            ttk._dict_from_tcltuple((MockTclObj('-padding'),
                                     [MockTclObj('1'), 2,
                                      MockTclObj('3m')])),
            {'padding': [1, 2, '3m']})
示例#2
0
 def test_dict_from_tcltuple(self):
     fakettuple = ('-a', '{1 2 3}', '-something', 'foo')
     self.assertEqual(ttk._dict_from_tcltuple(fakettuple, False), {'-a': '{1 2 3}',
      '-something': 'foo'})
     self.assertEqual(ttk._dict_from_tcltuple(fakettuple), {'a': '{1 2 3}',
      'something': 'foo'})
     self.assertFalse(ttk._dict_from_tcltuple(('single',)))
     sspec = MockStateSpec('a', 'b')
     self.assertEqual(ttk._dict_from_tcltuple(('-a', (sspec, 'val'))), {'a': [('a', 'b', 'val')]})
     self.assertEqual(ttk._dict_from_tcltuple((MockTclObj('-padding'), [MockTclObj('1'), 2, MockTclObj('3m')])), {'padding': [1, 2, '3m']})
示例#3
0
 def test_dict_from_tcltuple(self):
     fakettuple = ('-a', '{1 2 3}', '-something', 'foo')
     self.assertEqual(ttk._dict_from_tcltuple(fakettuple, False), {'-a': '{1 2 3}',
      '-something': 'foo'})
     self.assertEqual(ttk._dict_from_tcltuple(fakettuple), {'a': '{1 2 3}',
      'something': 'foo'})
     self.assertFalse(ttk._dict_from_tcltuple(('single',)))
     sspec = MockStateSpec('a', 'b')
     self.assertEqual(ttk._dict_from_tcltuple(('-a', (sspec, 'val'))), {'a': [('a', 'b', 'val')]})
     self.assertEqual(ttk._dict_from_tcltuple((MockTclObj('-padding'), [MockTclObj('1'), 2, MockTclObj('3m')])), {'padding': [1, 2, '3m']})
示例#4
0
    def test_dict_from_tcltuple(self):
        fakettuple = ("-a", "{1 2 3}", "-something", "foo")

        self.assertEqual(ttk._dict_from_tcltuple(fakettuple, False), {"-a": "{1 2 3}", "-something": "foo"})

        self.assertEqual(ttk._dict_from_tcltuple(fakettuple), {"a": "{1 2 3}", "something": "foo"})

        # passing a tuple with a single item should return an empty dict,
        # since it tries to break the tuple by pairs.
        self.assertFalse(ttk._dict_from_tcltuple(("single",)))

        sspec = MockStateSpec("a", "b")
        self.assertEqual(ttk._dict_from_tcltuple(("-a", (sspec, "val"))), {"a": [("a", "b", "val")]})

        self.assertEqual(
            ttk._dict_from_tcltuple((MockTclObj("-padding"), [MockTclObj("1"), 2, MockTclObj("3m")])),
            {"padding": [1, 2, "3m"]},
        )
示例#5
0
    def test_dict_from_tcltuple(self):
        fakettuple = ('-a', '{1 2 3}', '-something', 'foo')

        self.assertEqual(ttk._dict_from_tcltuple(fakettuple, False),
            {'-a': '{1 2 3}', '-something': 'foo'})

        self.assertEqual(ttk._dict_from_tcltuple(fakettuple),
            {'a': '{1 2 3}', 'something': 'foo'})

        # passing a tuple with a single item should return an empty dict,
        # since it tries to break the tuple by pairs.
        self.assertFalse(ttk._dict_from_tcltuple(('single', )))

        sspec = MockStateSpec('a', 'b')
        self.assertEqual(ttk._dict_from_tcltuple(('-a', (sspec, 'val'))),
            {'a': [('a', 'b', 'val')]})

        self.assertEqual(ttk._dict_from_tcltuple((MockTclObj('-padding'),
            [MockTclObj('1'), 2, MockTclObj('3m')])),
            {'padding': [1, 2, '3m']})