diff --git a/tests/parse/test_clear_notes.py b/tests/parse/test_clear_notes.py index d2ec3a4..14707d8 100644 --- a/tests/parse/test_clear_notes.py +++ b/tests/parse/test_clear_notes.py @@ -12,7 +12,7 @@ ParseTask, ) from src.syntax import SyntaxStream -from tests.parse.templates import template_parse_invalid, template_parse_valid +from tests.parse.templates import template_parse_invalid from tests.parse.test_parse import draw_parse_context from tests.test_syntax import draw_token_by_value, draw_syntax_token diff --git a/tests/parse/test_clear_notes.py b/tests/parse/test_clear_notes.py index d2ec3a4..14707d8 100644 --- a/tests/parse/test_clear_notes.py +++ b/tests/parse/test_clear_notes.py @@ -12,7 +12,7 @@ ParseTask, ) from src.syntax import SyntaxStream -from tests.parse.templates import template_parse_invalid, template_parse_valid +from tests.parse.templates import template_parse_invalid from tests.parse.test_parse import draw_parse_context from tests.test_syntax import draw_token_by_value, draw_syntax_token diff --git a/tests/parse/test_note.py b/tests/parse/test_note.py index e4b53f5..221d828 100644 --- a/tests/parse/test_note.py +++ b/tests/parse/test_note.py @@ -6,7 +6,6 @@ booleans, composite, lists, - one_of, ) from src.parse import ( @@ -62,8 +61,8 @@ # - Error if there is no StartNote node at all # - Error if StartNote is not a SyntaxType.TOKEN # - Error if StartNote's token value is not "StartNote" -@composite -def draw_syntax_note_invalid_nostartnote(draw): +@template_parse_invalid(NoteSkipper().skip_note) +def test_parse_note_invalid_nostartnote(draw): (tokens, _) = draw(draw_syntax_note_valid()) parent_context = draw(draw_parse_context()) if draw(booleans()): @@ -87,8 +86,8 @@ # Generate note with a StartNote token in it # We expect the following behaviour: # - Error if a StartNote token is in the note content -@composite -def draw_syntax_note_invalid_extrastartnote(draw): +@template_parse_invalid(NoteSkipper().skip_note) +def test_parse_note_invalid_extrastartnote(draw): (tokens, _) = draw(draw_syntax_note_valid()) start = draw(draw_token_by_value("StartNote")) new_tokens = insert_random(draw, tokens, start) @@ -101,21 +100,10 @@ # Generate note without EndNote # We expect the following behaviour: # - Error if there is no EndNote node at all -@composite -def draw_syntax_note_invalid_noendnote(draw): +@template_parse_invalid(NoteSkipper().skip_note) +def test_parse_note_invalid_noendnote(draw): (tokens, _) = draw(draw_syntax_note_valid()) parent_context = draw(draw_parse_context()) context = ParseContext(ParseTask.PARSE_NOTE, tokens[0], parent_context) error = ParseErrorException(ParseError.NO_TOKEN, None, None, context) return (tokens[0:-1], error, parent_context) - - -# Test that parse_note errors in invalid cases -@template_parse_invalid(NoteSkipper().skip_note) -def test_parse_note_invalid(draw): - strategies = [ - draw_syntax_note_invalid_nostartnote(), - draw_syntax_note_invalid_extrastartnote(), - draw_syntax_note_invalid_noendnote(), - ] - return draw(one_of(strategies)) diff --git a/tests/parse/test_clear_notes.py b/tests/parse/test_clear_notes.py index d2ec3a4..14707d8 100644 --- a/tests/parse/test_clear_notes.py +++ b/tests/parse/test_clear_notes.py @@ -12,7 +12,7 @@ ParseTask, ) from src.syntax import SyntaxStream -from tests.parse.templates import template_parse_invalid, template_parse_valid +from tests.parse.templates import template_parse_invalid from tests.parse.test_parse import draw_parse_context from tests.test_syntax import draw_token_by_value, draw_syntax_token diff --git a/tests/parse/test_note.py b/tests/parse/test_note.py index e4b53f5..221d828 100644 --- a/tests/parse/test_note.py +++ b/tests/parse/test_note.py @@ -6,7 +6,6 @@ booleans, composite, lists, - one_of, ) from src.parse import ( @@ -62,8 +61,8 @@ # - Error if there is no StartNote node at all # - Error if StartNote is not a SyntaxType.TOKEN # - Error if StartNote's token value is not "StartNote" -@composite -def draw_syntax_note_invalid_nostartnote(draw): +@template_parse_invalid(NoteSkipper().skip_note) +def test_parse_note_invalid_nostartnote(draw): (tokens, _) = draw(draw_syntax_note_valid()) parent_context = draw(draw_parse_context()) if draw(booleans()): @@ -87,8 +86,8 @@ # Generate note with a StartNote token in it # We expect the following behaviour: # - Error if a StartNote token is in the note content -@composite -def draw_syntax_note_invalid_extrastartnote(draw): +@template_parse_invalid(NoteSkipper().skip_note) +def test_parse_note_invalid_extrastartnote(draw): (tokens, _) = draw(draw_syntax_note_valid()) start = draw(draw_token_by_value("StartNote")) new_tokens = insert_random(draw, tokens, start) @@ -101,21 +100,10 @@ # Generate note without EndNote # We expect the following behaviour: # - Error if there is no EndNote node at all -@composite -def draw_syntax_note_invalid_noendnote(draw): +@template_parse_invalid(NoteSkipper().skip_note) +def test_parse_note_invalid_noendnote(draw): (tokens, _) = draw(draw_syntax_note_valid()) parent_context = draw(draw_parse_context()) context = ParseContext(ParseTask.PARSE_NOTE, tokens[0], parent_context) error = ParseErrorException(ParseError.NO_TOKEN, None, None, context) return (tokens[0:-1], error, parent_context) - - -# Test that parse_note errors in invalid cases -@template_parse_invalid(NoteSkipper().skip_note) -def test_parse_note_invalid(draw): - strategies = [ - draw_syntax_note_invalid_nostartnote(), - draw_syntax_note_invalid_extrastartnote(), - draw_syntax_note_invalid_noendnote(), - ] - return draw(one_of(strategies)) diff --git a/tests/parse/test_text.py b/tests/parse/test_text.py index 67e37f4..f18d760 100644 --- a/tests/parse/test_text.py +++ b/tests/parse/test_text.py @@ -6,7 +6,6 @@ booleans, composite, lists, - one_of, ) from src.parse import ( @@ -70,8 +69,8 @@ # - Error if there is no StartText node at all # - Error if StartText is not a SyntaxType.TOKEN # - Error if StartText's token value is not "StartText" -@composite -def draw_syntax_text_invalid_nostarttext(draw): +@template_parse_invalid(Parser().parse_text) +def test_parse_text_invalid_nostarttext(draw): (tokens, _) = draw(draw_syntax_text_valid()) parent_context = draw(draw_parse_context()) if draw(booleans()): @@ -95,7 +94,7 @@ # Generate text with invalid content tokens # We expect the following behaviour: # - Error if a content token is not a SyntaxType.TOKEN -@composite +@template_parse_invalid(Parser().parse_text) def draw_syntax_text_invalid_invalidcontent(draw): (tokens, _) = draw(draw_syntax_text_valid()) token = draw(draw_syntax_random()) @@ -110,7 +109,7 @@ # Generate text with a StartText token in it # We expect the following behaviour: # - Error if a StartText token is in the text content -@composite +@template_parse_invalid(Parser().parse_text) def draw_syntax_text_invalid_extrastarttext(draw): (tokens, _) = draw(draw_syntax_text_valid()) start = draw(draw_token_by_value("StartText")) @@ -124,22 +123,10 @@ # Generate text without EndText # We expect the following behaviour: # - Error if there is no EndText node at all -@composite -def draw_syntax_text_invalid_noendtext(draw): +@template_parse_invalid(Parser().parse_text) +def test_parse_text_invalid_noendtext(draw): (tokens, _) = draw(draw_syntax_text_valid()) parent_context = draw(draw_parse_context()) context = ParseContext(ParseTask.PARSE_TEXT, tokens[0], parent_context) error = ParseErrorException(ParseError.NO_TOKEN, None, None, context) return (tokens[0:-1], error, parent_context) - - -# Test that parse_text errors in invalid cases -@template_parse_invalid(Parser().parse_text) -def test_parse_text_invalid(draw): - strategies = [ - draw_syntax_text_invalid_nostarttext(), - draw_syntax_text_invalid_invalidcontent(), - draw_syntax_text_invalid_extrastarttext(), - draw_syntax_text_invalid_noendtext(), - ] - return draw(one_of(strategies))