Esempio n. 1
0
 def test_populate_recursive(self):
     li = TempyList()
     li.populate({1: None, 2: ['a', 'b', 'c'], 3: {'test': [1, 2, 3]}})
     self.assertIsInstance(li, Ul)
     self.assertEqual(len(li), 3)
     self.assertIsInstance(li[0], Li)
     self.assertIsInstance(li[1][1], Ul)
     self.assertEqual(len(li[1][1]), 3)
     self.assertIsInstance(li[1][1][0], Li)
Esempio n. 2
0
    def test_create_empty(self):
        li = TempyList()
        self.assertIsInstance(li, Ul)
        self.assertEqual(len(li), 0)

        li = TempyList(Ol)
        self.assertIsInstance(li, Ol)
        self.assertEqual(len(li), 0)

        li = TempyList('Ol')
        self.assertIsInstance(li, Ol)
        self.assertEqual(len(li), 0)

        with self.assertRaises(WidgetError):
            li = TempyList('Wrong')
Esempio n. 3
0
    def test_create_full(self):
        li = TempyList(struct=[1, 2, 3])
        self.assertIsInstance(li, Ul)
        self.assertEqual(len(li), 3)
        self.assertIsInstance(li[0], Li)
        self.assertTrue(1 in li[0])

        li = TempyList(struct={1, 2, 3})
        self.assertIsInstance(li, Ul)
        self.assertEqual(len(li), 3)
        self.assertIsInstance(li[0], Li)

        li = TempyList(struct={1: None, 2: None, 3: None, '_typ': Ol})
        self.assertIsInstance(li, Ol)
        self.assertEqual(len(li), 3)
        self.assertIsInstance(li[0], Li)
Esempio n. 4
0
 def test_populate_empty(self):
     li = TempyList()
     li.populate([1, 2, 3])
     self.assertIsInstance(li, Ul)
     self.assertEqual(len(li), 3)
     self.assertIsInstance(li[0], Li)
     with self.assertRaises(WidgetDataError):
         li.populate('wrong type')
Esempio n. 5
0
 def test_populate_empty(self):
     li = TempyList()
     li.populate([1, 2, 3])
     self.assertIsInstance(li, Ul)
     self.assertEqual(len(li), 3)
     self.assertIsInstance(li[0], Li)
     with self.assertRaises(WidgetDataError):
         li.populate('wrong type')
     li = TempyList(typ=Dl)
     li.populate({1: 'one', 2: 'two', 34: ['three', 'four']})
     self.assertIsInstance(li, Dl)
     self.assertEqual(len(li), 7)
     self.assertIsInstance(li[0], Dt)
     self.assertIsInstance(li[1], Dd)
     self.assertIsInstance(li[6], Dd)
     with self.assertRaises(WidgetDataError):
         li.populate('wrong type')