diff --git a/tests/parse/templates.py b/tests/parse/templates.py index e0b1b65..ad01fdc 100644 --- a/tests/parse/templates.py +++ b/tests/parse/templates.py @@ -2,6 +2,7 @@ # Copyright 2022 Jookia from hypothesis import given +from hypothesis.strategies import integers from src.parse import SyntaxStream from tests.test_syntax import draw_syntax_random @@ -29,3 +30,10 @@ assert stream.pop() is None return lambda func: do + + +# Inserts an element at a random place in a list +def insert_random(draw, list, data): + pos = draw(integers(min_value=1, max_value=(len(list) - 1))) + new_data = list[0:pos] + [data] + list[pos:] + return new_data diff --git a/tests/parse/test_note.py b/tests/parse/test_note.py index 0f8fd33..a453d01 100644 --- a/tests/parse/test_note.py +++ b/tests/parse/test_note.py @@ -4,7 +4,6 @@ from hypothesis import assume, given from hypothesis.strategies import ( booleans, - integers, composite, lists, one_of, @@ -18,7 +17,7 @@ ParseTask, ) from src.syntax import SyntaxStream, SyntaxType -from tests.parse.templates import template_parse_valid +from tests.parse.templates import insert_random, template_parse_valid from tests.parse.test_parse import draw_parse_context from tests.test_syntax import ( draw_token_by_value, @@ -27,13 +26,6 @@ ) -# Inserts an element at a random place in a list -def insert_random(draw, list, data): - pos = draw(integers(min_value=1, max_value=(len(list) - 1))) - new_data = list[0:pos] + [data] + list[pos:] - return new_data - - # Draws a random token suitable for note building @composite def draw_note_value_token(draw): diff --git a/tests/parse/test_text.py b/tests/parse/test_text.py index b3d9c20..f758120 100644 --- a/tests/parse/test_text.py +++ b/tests/parse/test_text.py @@ -5,7 +5,6 @@ from hypothesis.strategies import ( booleans, composite, - integers, lists, one_of, ) @@ -18,7 +17,7 @@ Parser, ) from src.syntax import Syntax, SyntaxStream, SyntaxType -from tests.parse.templates import template_parse_valid +from tests.parse.templates import insert_random, template_parse_valid from tests.parse.test_parse import draw_parse_context from tests.test_syntax import ( draw_token_by_value, @@ -27,13 +26,6 @@ ) -# Inserts an element at a random place in a list -def insert_random(draw, list, data): - pos = draw(integers(min_value=1, max_value=(len(list) - 1))) - new_data = list[0:pos] + [data] + list[pos:] - return new_data - - # Draws a random token suitable for text building @composite def draw_text_value_token(draw):