Reached 100% coverage and added tests for reparse. Still some errors on this optionnal parameter.
This commit is contained in:
parent
a556466999
commit
ef06018559
|
|
@ -205,7 +205,7 @@ def reparse(parse_element):
|
||||||
:return: returns a function parsing given match with specified parsing element
|
:return: returns a function parsing given match with specified parsing element
|
||||||
"""
|
"""
|
||||||
def _reparse(original_string, _, __):
|
def _reparse(original_string, _, __):
|
||||||
parse_element.parse_string(original_string)
|
return parse_element.parse_string(original_string)
|
||||||
|
|
||||||
return _reparse
|
return _reparse
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ dict_advanced_syntax_input_and_expected_output = {
|
||||||
"aze,/.",
|
"aze,/.",
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
), __GL()),
|
), __GL(), __XF),
|
||||||
("{aze,/.}[a=12]", (
|
("{aze,/.}[a=12]", (
|
||||||
sy.OptionalToken([
|
sy.OptionalToken([
|
||||||
sy.OptionalInsertToken([
|
sy.OptionalInsertToken([
|
||||||
|
|
@ -183,7 +183,7 @@ dict_advanced_syntax_input_and_expected_output = {
|
||||||
sy.BeAssignToken([["a", 12]]),
|
sy.BeAssignToken([["a", 12]]),
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
), __GL()),
|
), __GL(), __XF),
|
||||||
("{aze!=}", (
|
("{aze!=}", (
|
||||||
sy.OptionalToken([
|
sy.OptionalToken([
|
||||||
sy.OptionalInsertToken([
|
sy.OptionalInsertToken([
|
||||||
|
|
@ -233,7 +233,7 @@ dict_advanced_syntax_input_and_expected_output = {
|
||||||
"azer!=",
|
"azer!=",
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
), __GL()),
|
), __GL(), __XF),
|
||||||
],
|
],
|
||||||
# Enhanced Text
|
# Enhanced Text
|
||||||
"enhanced_text": [
|
"enhanced_text": [
|
||||||
|
|
@ -558,6 +558,15 @@ list_of_text_input_and_readable_output = [
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
list_of_reparsing_input_and_expected_output = [
|
||||||
|
("reparse_test", "enhanced_text", sy.TextToken(["reparse_test"]), __GL()) # TODO : add more test cases
|
||||||
|
]
|
||||||
|
final_list_of_reparsing_input_and_expected_output = [
|
||||||
|
ptp(item[0], item[1], item[2], item[3], id=f'{item[0]} (line:{item[3]})', marks=item[4:])
|
||||||
|
for item in list_of_reparsing_input_and_expected_output
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("token_name,token_class", list_of_token_types.items())
|
@pytest.mark.parametrize("token_name,token_class", list_of_token_types.items())
|
||||||
def test_token_type_exists(token_name, token_class):
|
def test_token_type_exists(token_name, token_class):
|
||||||
"""
|
"""
|
||||||
|
|
@ -640,6 +649,9 @@ def test_semantic_type_eq():
|
||||||
st1 = sy.SemanticType([1, 2, 3])
|
st1 = sy.SemanticType([1, 2, 3])
|
||||||
st2 = sy.SemanticType([1, 2, 3, 4])
|
st2 = sy.SemanticType([1, 2, 3, 4])
|
||||||
assert st1 != st2
|
assert st1 != st2
|
||||||
|
st1 = sy.SemanticType([[1, 2, 4]])
|
||||||
|
st2 = sy.SemanticType([[1, 2, 3]])
|
||||||
|
assert st1 != st2
|
||||||
|
|
||||||
|
|
||||||
def find_expression_from_str(expression_str):
|
def find_expression_from_str(expression_str):
|
||||||
|
|
@ -754,3 +766,16 @@ def test_weird_markup():
|
||||||
|
|
||||||
assert sy.readable_markup(
|
assert sy.readable_markup(
|
||||||
[sy.EmptySemanticType("weird"), empty_token, WeirdClass()]) == "weird <[NOC] weird /> weird"
|
[sy.EmptySemanticType("weird"), empty_token, WeirdClass()]) == "weird <[NOC] weird /> weird"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("original_string, reparse_with, expected_output, line_test",
|
||||||
|
final_list_of_reparsing_input_and_expected_output)
|
||||||
|
def test_reparse(original_string, reparse_with, expected_output, line_test):
|
||||||
|
"""
|
||||||
|
Test the reparse function
|
||||||
|
"""
|
||||||
|
expression = find_expression_from_str(reparse_with)
|
||||||
|
reparse_action = pyparsing.Word(pyparsing.alphanums).add_parse_action(sy.reparse(expression))
|
||||||
|
reparse_result = reparse_action.parseString(original_string)
|
||||||
|
assert reparse_result is not None
|
||||||
|
assert reparse_result[0] == expected_output
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue