diff --git a/tests/parse/templates.py b/tests/parse/templates.py index b1db977..1049f1a 100644 --- a/tests/parse/templates.py +++ b/tests/parse/templates.py @@ -6,7 +6,7 @@ from src.parse import ParseErrorException from src.token import TokenStream -from tests.parse.test_parse import draw_parse_context +from tests.parse.test_parse import static_parse_context from tests.test_token import draw_token_random @@ -45,7 +45,7 @@ # Test that something parses incorrectly # We expect the following behaviour: # - The decoration supplies a parser function -# - The decorated function takes a generated parse context +# - The decorated function takes a parse context # - The decorated function generates input tokens and an error # - Parsing causes an error # - The parse error is as expected @@ -53,7 +53,7 @@ # Wrapper to add parse_context to our test_data @composite def wrapper(draw, func): - context = draw(draw_parse_context()) + context = static_parse_context() (tokens, error) = draw(composite(func)(context)) return (tokens, error, context) diff --git a/tests/parse/test_parse.py b/tests/parse/test_parse.py index 3711dc7..66cb222 100644 --- a/tests/parse/test_parse.py +++ b/tests/parse/test_parse.py @@ -19,7 +19,7 @@ ) from src.token import TokenStream from tests.templates import template_test_structure -from tests.test_token import draw_token_random +from tests.test_token import draw_token_random, static_token # Draws a random parse task @@ -36,6 +36,13 @@ return ParseContext(task, token, None) +# Static parse context +def static_parse_context(): + task = ParseTask.TEST_TASK + token = static_token() + return ParseContext(task, token, None) + + # Test parse context structure @template_test_structure( ParseContext, diff --git a/tests/test_token.py b/tests/test_token.py index 0ac8098..140b057 100644 --- a/tests/test_token.py +++ b/tests/test_token.py @@ -139,6 +139,11 @@ return token +# Static token +def static_token(): + return Token("Hello world!", static_token_location()) + + # Test token structure @template_test_structure( Token,