def test_delitem(self): expr = Expression([0, 1, 2, 3, 4, 5, 6]) del expr[0] assert_equal(expr, Expression([1, 2, 3, 4, 5, 6])) with assert_raises_str(IndexError, 'pop index of out range'): expr.pop(6) del expr[5] assert_equal(expr, Expression([1, 2, 3, 4, 5])) del expr[-1] assert_equal(expr, Expression([1, 2, 3, 4])) del expr[-2] assert_equal(expr, Expression([1, 2, 4])) del expr[1] assert_equal(expr, Expression([1, 4])) del expr[1:] assert_equal(expr, Expression([1])) del expr[:] assert_equal(expr, Expression([])) for i in range(-2, 3): with assert_raises_str(IndexError, 'pop from empty list'): del expr[i]
def test_delitem(self): expr = Expression([0, 1, 2, 3, 4, 5, 6]) del expr[0] assert_equal(expr, Expression([1, 2, 3, 4, 5, 6])) with assert_raises_str(IndexError, 'pop index of out range'): expr.pop(6) del expr[5] assert_equal(expr, Expression([1, 2, 3, 4, 5])) del expr[-1] assert_equal(expr, Expression([1, 2, 3, 4])) del expr[-2] assert_equal(expr, Expression([1, 2, 4])) del expr[1] assert_equal(expr, Expression([1, 4])) del expr[1:] assert_equal(expr, Expression([1])) del expr[:] assert_equal(expr, Expression([])) for i in range(-2, 3): with assert_raises_str(IndexError, 'pop from empty list'): del expr[i]
def test_pop(self): expr = Expression([0, 1, 2, 3, 4, 5, 6]) assert_equal(expr.pop(0), Expression(0)) assert_equal(expr, Expression([1, 2, 3, 4, 5, 6])) with assert_raises_str(IndexError, 'pop index of out range'): expr.pop(6) assert_equal(expr.pop(5), Expression(6)) assert_equal(expr, Expression([1, 2, 3, 4, 5])) assert_equal(expr.pop(-1), Expression(5)) assert_equal(expr, Expression([1, 2, 3, 4])) assert_equal(expr.pop(-2), Expression(3)) assert_equal(expr, Expression([1, 2, 4])) assert_equal(expr.pop(1), Expression(2)) assert_equal(expr, Expression([1, 4])) expr.pop() expr.pop() with assert_raises_str(IndexError, 'pop from empty list'): expr.pop() for i in range(-2, 3): with assert_raises_str(IndexError, 'pop from empty list'): expr.pop(i)
def test_pop(self): expr = Expression([0, 1, 2, 3, 4, 5, 6]) assert_equal(expr.pop(0), Expression(0)) assert_equal(expr, Expression([1, 2, 3, 4, 5, 6])) with assert_raises_str(IndexError, 'pop index of out range'): expr.pop(6) assert_equal(expr.pop(5), Expression(6)) assert_equal(expr, Expression([1, 2, 3, 4, 5])) assert_equal(expr.pop(-1), Expression(5)) assert_equal(expr, Expression([1, 2, 3, 4])) assert_equal(expr.pop(-2), Expression(3)) assert_equal(expr, Expression([1, 2, 4])) assert_equal(expr.pop(1), Expression(2)) assert_equal(expr, Expression([1, 4])) expr.pop() expr.pop() with assert_raises_str(IndexError, 'pop from empty list'): expr.pop() for i in range(-2, 3): with assert_raises_str(IndexError, 'pop from empty list'): expr.pop(i)