Exemple #1
0
def test_calc_can_consume_valid_token():
    """Test that a :class:`Calc` can consume a valid :class:`Token`."""
    input_text = "1+1"
    calc = Calc(text=input_text)
    # Note: Since _next_token advances position one cannot simply
    # >>> calc.current_token = Token(INTEGER, 1)
    # The _next_token method MUST be called or this test will fail.
    calc.current_token = calc._next_token()
    calc._consume_token(INTEGER)
    assert calc.current_token.type == PLUS