sh_cpl/unittests/unittests_query/iterable_test_case.py

35 lines
948 B
Python
Raw Permalink Normal View History

2021-07-26 15:48:42 +02:00
import unittest
from cpl_query.extension.list import List
2022-05-26 15:53:23 +02:00
class IterableTestCase(unittest.TestCase):
2021-07-26 15:48:42 +02:00
def setUp(self) -> None:
self._list = List(int)
def _clear(self):
self._list.clear()
self.assertEqual(self._list, [])
def test_append(self):
self._list.append(1)
self._list.append(2)
self._list.append(3)
2022-09-13 19:33:26 +02:00
self.assertEqual(self._list.to_list(), [1, 2, 3])
2023-02-20 15:55:20 +01:00
self.assertRaises(Exception, lambda v: self._list.append(v), "3")
2022-09-14 23:01:52 +02:00
def test_assign(self):
self._list.append(1)
self._list.append(2)
self._list.append(3)
self._list[0] = 42
self.assertEqual(self._list[0], 42)
self._list[0] = 1
self._list.append(42)
self.assertEqual(self._list[3], 42)
del self._list[3]
self.assertEqual(self._list.to_list(), [1, 2, 3])
2023-02-20 15:55:20 +01:00
self.assertRaises(Exception, lambda v: self._list.append(v), "3")