Skip to content

Commit

Permalink
Cover missing parser code path with a test
Browse files Browse the repository at this point in the history
  • Loading branch information
plamut committed Sep 2, 2020
1 parent 3b94a55 commit 767e60b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/unit/line_arg_parser/test_parser.py
Expand Up @@ -79,6 +79,22 @@ def test_destination_var_unexpected_input(parser_class):
parser.destination_var()


def test_option_value_unexpected_input(parser_class):
from google.cloud.bigquery.ipython_magics.line_arg_parser import ParseError
from google.cloud.bigquery.ipython_magics.line_arg_parser import TokenType
from google.cloud.bigquery.ipython_magics.line_arg_parser.lexer import Token

# A simple iterable of Tokens is sufficient.
fake_lexer = [
Token(TokenType.UNKNOWN, lexeme="@!#", pos=8),
Token(TokenType.OPTION_SPEC, lexeme="", pos=13),
]
parser = parser_class(fake_lexer)

with pytest.raises(ParseError, match=r"Unknown input.*position 8.*@!#.*"):
parser.option_value()


def test_dict_items_empty_dict(parser_class):
from google.cloud.bigquery.ipython_magics.line_arg_parser import TokenType
from google.cloud.bigquery.ipython_magics.line_arg_parser.lexer import Token
Expand Down

0 comments on commit 767e60b

Please sign in to comment.