Пример #1
0
    def test_setitem_index_present(self) -> None:
        """test __setitem__ function when index in inbound"""
        lst = LinkedList([0, 1, 2, 3, 4, 5, 6])

        lst.__setitem__(1, 100)

        assert lst.to_list() == [0, 100, 2, 3, 4, 5, 6]
Пример #2
0
    def test_setitem_index_not_present(self) -> None:
        """test __setitem__ when index is out of bound"""
        lst = LinkedList([0, 1, 2, 3, 4, 5, 6])

        try:
            lst.__setitem__(10, 100)
        except IndexError:
            assert True
        except Exception as exp:
            if exp != IndexError:
                assert False