Ejemplo n.º 1
0
 def test_reverse(self):
     "Fluent way."
     flist = FluentList([2, 1, 3]).reverse()
     self.assertIsInstance(flist, FluentList)
     self.assertEqual([3, 1, 2], flist)
Ejemplo n.º 2
0
 def test_replace01(self):
     flist = FluentList([1, 2])
     flist.replace(old=1, new=3)
     self.assertEqual([3, 2], flist)
Ejemplo n.º 3
0
 def test_clear(self):
     "Fluent way."
     flist = FluentList([2, 1]).clear()
     self.assertIsInstance(flist, FluentList)
     self.assertFalse(flist)
Ejemplo n.º 4
0
 def test_sort(self):
     "Fluent way."
     flist = FluentList([2, 1, 3]).sort()
     self.assertIsInstance(flist, FluentList)
     self.assertEqual([1, 2, 3], flist)
Ejemplo n.º 5
0
 def test_extend(self):
     "Fluent way."
     flist = FluentList(['1']).extend(['2', '3'])
     self.assertIsInstance(flist, FluentList)
     self.assertEqual(['1', '2', '3'], flist)
Ejemplo n.º 6
0
 def test_insert(self):
     "Fluent way."
     flist = FluentList([1, 3]).insert(1, 2)
     self.assertIsInstance(flist, FluentList)
     self.assertEqual([1, 2, 3], flist)
Ejemplo n.º 7
0
 def test_remove(self):
     "Fluent way."
     flist = FluentList([1, 2, 3]).remove(2)
     self.assertIsInstance(flist, FluentList)
     self.assertEqual([1, 3], flist)
Ejemplo n.º 8
0
 def test_append(self):
     "Fluent way."
     flist = FluentList([1]).append(2).append(3)
     self.assertIsInstance(flist, FluentList)
     self.assertEqual([1, 2, 3], flist)
Ejemplo n.º 9
0
    def test_inherited(self):
        flist = FluentList([1, 2])
        self.assertTrue(flist)
        self.assertEqual(2, len(flist))
        self.assertEqual(2, flist[1])

        with self.assertRaises(ValueError):
            flist.index(3)

        flist.append(3)
        self.assertEqual(3, len(flist))
        self.assertEqual(2, flist.index(3))

        flist.remove(2)
        self.assertEqual([1, 3], flist)

        flist.insert(1, 2)
        self.assertEqual([1, 2, 3], flist)

        flist.clear()
        self.assertFalse(flist)
Ejemplo n.º 10
0
    def test_replace03(self):
        "Not found."
        flist = FluentList([1])

        with self.assertRaises(ValueError):
            flist.replace(old=2, new=3)
Ejemplo n.º 11
0
 def test_replace02(self):
     "Other index."
     flist = FluentList([1, 2])
     flist.replace(old=2, new=3)
     self.assertEqual([1, 3], flist)